Say i have a 256 byte file. How many additions or multiplications can a modern computer perform on them using c++ ?

I've been working on this c++ compression project that does a lot of calculations. I use Dev-cpp,and am a amateur programmer,i've not used pointers,vectors or anything fancy yet,anyway my comp takes about 10 secs to just reduce it by a few bytes. How much faster can i expect it to run if i use vectors and pointers ?

And finally When a computer has a spec of 2GHZ,and a cycle period of 2,does it mean it performs a billion instructions ? and what constitutes a instruction ? a file transfer,addition, how many of these operations can fit in 1 instruction ? Does assinging or incrementing a variable count a 1 instruction ?

Thanks a lot for your time and response.

I'm not exactly sure what you mean by adding or multiplying a file. Also what do mean by reducing the file by a few bytes. A AMD 2 GHZ processor single core will do about 3500 MIPS or 3500000000 instructions per second. A 2 GHZ processor will have 2 billion CPS so if you instruction needs 10 cycles to complete you could do it 200,000,000 times in one second. As for what is an instruction its basically anything you tell the processor to do and instructions have different CPI depending on how complex they are.

Comments
nice answer

It is impossible to say how much faster your code wil run, if any faster atall, if you 'use vectors or pointers'. Generally using vectors will even be slower than using raw pointers.

I'm not sure how you expect to see a performance increase by using pointers... in certain areas using a pointer can speed something up, but it would probably be a better idea to look at your algorithm first (maybe even profile it to see where the bottlenecks are, if it's really that important).

Thinking about how many instructions your CPU is going to execute doesn't really have a lot of meaning, as Nathan mentioned a CPU can perform 2 billion instructions in a second but that says nothing about how many instructions your running process gets to execute, in fact it will probably not even run on the CPU consequtively for an entire second.

And as to your question regarding an instruction... the examples you mention like a file transfer could consist of thousands of instructions(and a lot of time waiting for the hardware, in which case the CPU can decide to calculate something for another process while waiting).

This article has been dead for over six months. Start a new discussion instead.