H
Hans Mull
Hi!
I've created a benchmark tool which uses Agner Fog's asmlib to count the
clockcycles a function takes. I 'm using it to measure the
MersenneTwister.h speed.
Sourcecode is here:
http://code.google.com/p/multirng/source/browse/trunk/benchmarks/benchmarks.h
(the main function just calls this functions)
When I run on a P4 Prescott (MinGW with GCC4, Win XP MediaCenter) with
-O3 -fexpensive-optimizations and Prescott-specific optimizations, it
shows me that e.g. mtr.rand() takes ~1200 clockcycles. I think this is
realistic.
But when I write something like
time[0] = ReadTSC();
for(int i = 0;i < NUMTESTS;i++) rand();
time[1] = ReadTSC();
and
cout << "rand() time:" << (time[1]-time[0])/NUMTESTS << endl;
it shows me that it (and the other functions too) takes only 20
clockcycles. Is this realistic? I think it's OK that when you call the
function it takes more clockcycles than in the average, but 20
clockcycles for creating a random number? However, even if I set
NUMTESTS to higher or lower values, the result remains the same (except
of a difference of about 3 or 4 clockcycles)
Thanks in advance, Hans
I've created a benchmark tool which uses Agner Fog's asmlib to count the
clockcycles a function takes. I 'm using it to measure the
MersenneTwister.h speed.
Sourcecode is here:
http://code.google.com/p/multirng/source/browse/trunk/benchmarks/benchmarks.h
(the main function just calls this functions)
When I run on a P4 Prescott (MinGW with GCC4, Win XP MediaCenter) with
-O3 -fexpensive-optimizations and Prescott-specific optimizations, it
shows me that e.g. mtr.rand() takes ~1200 clockcycles. I think this is
realistic.
But when I write something like
time[0] = ReadTSC();
for(int i = 0;i < NUMTESTS;i++) rand();
time[1] = ReadTSC();
and
cout << "rand() time:" << (time[1]-time[0])/NUMTESTS << endl;
it shows me that it (and the other functions too) takes only 20
clockcycles. Is this realistic? I think it's OK that when you call the
function it takes more clockcycles than in the average, but 20
clockcycles for creating a random number? However, even if I set
NUMTESTS to higher or lower values, the result remains the same (except
of a difference of about 3 or 4 clockcycles)
Thanks in advance, Hans