64-bit Windows running on Quad Opteron:
======
Report file for timing the various timers.
*** Key number is the avg time.
The smaller this number, the faster the timer.
QueryPerformanceFrequency() freq = 0 1804000000
method 0:
QueryPerfCntr..() 100 times
tot: 0 37602
avg: 376.020000
avg time: 2.08437e-007
method 0:
QueryPerfCntr..() 500 times
tot: 0 184766
avg: 369.532000
avg time: 2.0484e-007
method 0:
QueryPerfCntr..() 1000 times
tot: 0 368402
avg: 368.402000
avg time: 2.04214e-007
method 0:
QueryPerfCntr..() 10000 times
tot: 0 3680579
avg: 368.057900
avg time: 2.04023e-007
method 1:
GetTickCount() 100 times
tot: 0 2276
avg: 22.760000
avg time: 1.26164e-008
method 1:
GetTickCount() 500 times
tot: 0 7209
avg: 14.418000
avg time: 7.99224e-009
method 1:
GetTickCount() 1000 times
tot: 0 13423
avg: 13.423000
avg time: 7.44069e-009
method 1:
GetTickCount() 10000 times
tot: 0 130595
avg: 13.059500
avg time: 7.23919e-009
method 2:
TimeGetTime() 100 times
tot: 0 13170
avg: 131.700000
avg time: 7.30044e-008
method 2:
TimeGetTime() 500 times
tot: 0 53613
avg: 107.226000
avg time: 5.94379e-008
method 2:
TimeGetTime() 1000 times
tot: 0 106387
avg: 106.387000
avg time: 5.89728e-008
method 2:
TimeGetTime() 10000 times
tot: 0 1060592
avg: 106.059200
avg time: 5.87911e-008
method 3:
Pentium internal high-freq cntr() 100 times
tot: 0 1223
avg: 12.230000
avg time: 6.77938e-009
method 3:
Pentium internal high-freq cntr() 500 times
tot: 0 4580
avg: 9.160000
avg time: 5.07761e-009
method 3:
Pentium internal high-freq cntr() 1000 times
tot: 0 8026
avg: 8.026000
avg time: 4.449e-009
method 3:
Pentium internal high-freq cntr() 10000 times
tot: 0 78559
avg: 7.855900
avg time: 4.35471e-009
Quote from prophet:
Here is code that measures the overhead of various timer functions in windows:
http://developer.nvidia.com/object/timer_function_performance.html
On my dual Opteron I am seeing overheads of:
QueryPerformanceCounter: 238 ns
GetTickCount: 8 to 16 ns
TimeGetTime: 80 ns
Pentium internal timer: 7 ns
The Pentium internal timer has the least overhead because it is implemented in 4 assembly instructions without any system call. The system calls have higher, though not unacceptable overheads.
There is long-term drift with these timers. This is not a problem if one requires time differences between closely spaced events such as market ticks. Calibration techniques can be used to obtain millisecond or microsecond precision over minutes or hours. However, it is questionable why anyone would need even millisecond precision for elapsed times of more than a minute.