Page 1 of 1
Calculate MIPS in assembly language
Posted: Sun Dec 18, 2011 8:25 pm
by GAT
What would be the best way to calculate MIPS(Millions of instructions per second) for a CPU in x86 assembly?
Re: Calculate MIPS in assembly language
Posted: Sun Dec 18, 2011 9:10 pm
by Brendan
Hi,
GAT wrote:What would be the best way to calculate MIPS(Millions of instructions per second) for a CPU in x86 assembly?
There's only 2 ways:
- See how many instructions you can do in a fixed amount of time
- See how long it takes to do a fixed amount of instructions
The main problem is deciding which instructions (3 million "NOPs" per second is going to be very different to 3 million "DIV" instructions per second). You'd want to determine how often each instruction is used in "average" code and use that as the basis for your benchmark so that it indicates what average code can expect. However people have already done that and created a standardised benchmarks (e.g.
SPECint) so it'd probably be a good idea to base your code on their work.
Cheers,
Brendan
Re: Calculate MIPS in assembly language
Posted: Mon Dec 19, 2011 12:30 am
by Nessphoro
But wasn't there already a post about that on the Wiki?
Re: Calculate MIPS in assembly language
Posted: Mon Dec 19, 2011 12:46 am
by Brendan
Hi,
Nessphoro wrote:But wasn't there already a post about that on the Wiki?
I don't think so (I couldn't find one).
There is an article about
detecting the CPU speed but that doesn't help when you want instructions per second rather than cycles per second (e.g. consider a 1 GHz CPU that averages 4 instructions per cycle vs. a 4 GHz CPU that averages 1 instruction per cycle).
Cheers,
Brendan
Re: Calculate MIPS in assembly language
Posted: Tue Dec 20, 2011 2:31 am
by Solar
A cautious query: What do you need the MIPS
for? As Brendan pointed out, it is a very dicey metric...
If you need it to calibrate some busy-loop, the answer is simple: Measure how often the CPU executes your loop in a set amount of time. Ref.
BogoMips.