Cpu speed measuring
My measuring routine fails. in win32 environment (which is multithread) it measures the speed of my cpu for about 500+/- 50 mhz (and it is p3-500). I''m using rdtsc instruction to get cpu cycle clock. HOW TO OMIT that mistake?
routine alogorithm:
a=timer();
for (;
{
b=timer();
if (b!=a) break;
}
b=a;
c=rdtsc();
for (;
{
a=timer();
if (b!=a) break;
}
c=rdtsc-c;
cpu_speed=c*1000; // the period of time in timer() function is 1/1000s
You have to call a serializing CPU instruction (like cpuid) in order to get to-the-tick accurate readings, and need to make sure you''re not suffering from a cache miss penalty.
Also, time it for longer than 1ms - take at least 10 if not 100 or 1000. You can call Sleep(10), just make sure you start and end on a timer edge (like you do now) and divide by the time elapsed as indicated by the timer calls - don''t assume 1ms.
Magmai Kai Holmlor
- Not For Rent
Also, time it for longer than 1ms - take at least 10 if not 100 or 1000. You can call Sleep(10), just make sure you start and end on a timer edge (like you do now) and divide by the time elapsed as indicated by the timer calls - don''t assume 1ms.
Magmai Kai Holmlor
- Not For Rent
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement