Zeitmessen: QueryPerformanceCounter vs GetTickCount



Hallo zusammen!
Stehe gerade mal wieder auf dem Schlauch:
Ich möchte den Zeitverbrauchn einer Routine messen und bekomme bei der
Verwendung von QueryPerformanceCounter immer 0 ms -- hingegen mit
GetTickCount 2516 ms?!
Die zu messende Routine enthält übrigens ein sleep (2000). Merkwürdig
nicht?

Ganz oben steht:
-------------------------
QueryPerformanceFrequency(FreqY);

Zu Anfang der Routine steht:
-----------------------------------------
QueryPerformanceCounter(Time1);
Zeit := GetTickCount;

Und am Schluss:
-------------------------
QueryPerformanceCounter(Time2);
FPerformanceList.Add (' Procname: ' + Format('%.f ms',[(Time2 -
Time1) * 1000 / FreqY]));

bzw:
FPerformanceList.Add('GetTicount ' + (IntToStr(GetTickCount - Zeit) +
' ms'));

Was ist da los? Sollte QueryPerformanceCounter eine besondere
Initialisierung benötigen?
Übrigens ist QueryPerformanceFrequency(FreqY) = 3579545.

Ändere ich die Formatierung auf 3 Stellen ('%.3f ms'), bekomme ich bei
QueryPerformance 0,065ms und im GetTickCount immernoch 2516 ms. Hä?

Kann mir jemand mal schnell auf die Sprünge helfen?

Danke & Gruß
Jasmin
.



Relevant Pages

  • Re: GetTickCount
    ... The GetTickCount retries the number of milliseconds that have ... Zeitmessungen gibt es aber inzwischen genauere Quellen, ... ziemlich sicher das der Counter welcher mit QueryPerformanceCounter ... ausgelesen wird, durch den gleichen Timer wie GetTickCount gefüttert ...
    (de.comp.lang.delphi.misc)
  • RE: GetTickCount problem P4 hyperthread
    ... >> QueryPerformanceCounter ... >> and QueryPerformanceFrequency instead of GetTickCount. ... >> Vladimir Nesterovsky ... > computer to be in the same condition like the client, and the bug was ...
    (microsoft.public.dotnet.languages.vc)
  • Re: how to measure time which expire between two events
    ... Note that GetTickCount counts the amount of ... the values are fairly untrustworthy in terms of time spent in your code. ... QueryPerformanceCounter counts time in your thread. ... So the time returned by GetTickCount can't be trusted ...
    (microsoft.public.vc.mfc)
  • Re: high resolution elapsed time???
    ... resolution. ... Private Declare Function GetTickCount Lib "kernel32" As Long ... '// from the last time this routine was called. ... Dim THIS_TIME As Long ...
    (microsoft.public.vc.language)
  • Re: Negative difference between QueryPerformanceCounter values
    ... GetTickCount (in milliseconds) ... one millisesecond) is in fact completely random, causing inconsistent timing ... QueryPerformanceCounter works on their platform. ... Use GetTickCount, that's known to work. ...
    (microsoft.public.pocketpc.developer)

Loading