> I used the QueryPerformanceCounter and QueryPerformanceFrequency methods in
> my VC++ 6.0 projects to measure correct time spans, for example for timeouts,
[quoted text clipped - 10 lines]
>
> Thanks
Actually, that if you want high precision timing, I still recommend using
explicit Pinvoke the way you describe. In .NET you have access to
System.DateTime structure which is stated as 100 nanoseconds (1 / 10
millionth of a second). If that precision is good enough you should be able
to use that instead.
Thanks,
Kapil
Carl Daniel [VC++ MVP] - 03 May 2005 02:34 GMT
> Actually, that if you want high precision timing, I still recommend
> using explicit Pinvoke the way you describe. In .NET you have access
> to System.DateTime structure which is stated as 100 nanoseconds (1 /
> 10 millionth of a second). If that precision is good enough you
> should be able to use that instead.
Just to be clear: DateTime has 100 nanosecond resolution. It does not, by
any stretch have 100 nanosecond accuracy or precision. Rather, the
precision and accuracy are on the order of +/- 5-7ms (10-15ms tick time).
-cd
William DePalo [MVP VC++] - 03 May 2005 02:48 GMT
> Just to be clear: DateTime has 100 nanosecond resolution. It does not,
> by any stretch have 100 nanosecond accuracy or precision. Rather, the
> precision and accuracy are on the order of +/- 5-7ms (10-15ms tick time).
Absolutely right.
FWIW: while there are no guarantees as to minimum latencies on any version
of Windows (except _maybe_ CE, I dunno) you can get the precison down as low
as it will go by bracketing time sensitive sections of code with
timeBeginPeriod(1);
and
timeEndPeriod(1);
It's not at all obvious, but things like the smallest period you can Sleep()
change in the presence of those two inoccuous looking lines.
Regards,
Will