Re: Is timeGetTime monotonic and uniform?



On Sun, 03 Dec 2006 11:31:59 +0100,
=?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?= <martin@xxxxxxxxxxx>
wrote:

I'm looking for a way to measure durations on Windows
(i.e. differences between start and end time)
The stock GetSystemTimeAsFileTime is not appropriate,
as the result will be incorrect if the system time
is adjusted, e.g. due to the time service starting
(or manual adjustment).

Next candidate is GetTickCount(). I know this runs
over after 47d, but I wonder whether the description
"milliseconds since the system has started" is really
correct, given that it also says "This value is also affected
by adjustments made by the GetSystemTimeAdjustment function."

Next candidate is timeGetTime(). It has nearly the
same description as GetTickCount, but without the
remark that it is influenced by GetSystemTimeAdjustment.
Does that mean it is not influenced by time adjustments?
Or did they just leave that out of the description?

Are there any other functions I should use?

Regards,
Martin

The instruction I would use is RDTSC, which is an
assembler opcode (ReaD Time Stamp Counter)
that returns the CPU ticks since boot time in EDX:EAX.
Note that the tick rate varies as a function of the CPU
clock rate, which can be a serious problem on systems
that slow the clock for power-saving. Nonetheless, RDTSC
is still useful for many timing operations, such as code
optimization.

You can use the API function QueryPerformanceCounter
to obtain the same functionality as RDTSC, and then use
QueryPerformanceFrequency to get the CPU rate. I don't
know if QueryPerfomanceFrequency changes during
power saving, or if it is a system constant.

Best regards,


Bob Masta
dqatechATdaqartaDOTcom

D A Q A R T A
Data AcQuisition And Real-Time Analysis
www.daqarta.com
Home of DaqGen, the FREEWARE signal generator
.



Relevant Pages

  • Is timeGetTime monotonic and uniform?
    ... as the result will be incorrect if the system time ... Next candidate is GetTickCount(). ... remark that it is influenced by GetSystemTimeAdjustment. ... Does that mean it is not influenced by time adjustments? ...
    (microsoft.public.win32.programmer.mmedia)
  • Re: Stolen and degraded time and schedulers
    ... If you want accurate time accounting, don't use the TSC. ... The adjustments that I spoke of above are working regardless of ntp .. ... as does interrupt latency since the clock is essentially ... CPU does work as a timebase, then using the same warping mechanism would ...
    (Linux-Kernel)

Loading