[ntp:questions] micro-optimization

Martin Burnicki martin.burnicki at meinberg.de
Thu Mar 12 08:57:36 UTC 2009


David J Taylor wrote:
> David J Taylor wrote:
> []
>> On the Intel 6600 dual-core, 2.4GHz processor here, under XP, a RDTSC
>> takes about 4.2ns, and a OS call to timeGetTime takes about 11.8ns.
>> At least, they do if my measurement program is working correctly....
>> 
>> Haven't checked QPC.
>> 
>> Cheers,
>> David
> 
> And QueryPerformanceCounter takes some 226ns.  Oh dear!

Please keep in mind the QPC function also *tries* to handle the CPU specific
stuff consistent, if I understand the docs correctly.

>From the Microsoft SDK:
"On a multiprocessor computer, it should not matter which processor is
called. However, you can get different results on different processors due
to bugs in the basic input/output system (BIOS) or the hardware abstraction
layer (HAL)."

The latter is obviously the case with some AMD CPUs.

Anyway, if your code uses RDTSC directly insrtead of QPC then *your code*
may have to take care about this, and you have to take this also into
account if you compare execution times.

Of course I know you can limit these problems using explicite CPU affinity.

Martin
-- 
Martin Burnicki

Meinberg Funkuhren
Bad Pyrmont
Germany




More information about the questions mailing list