Einzelnen Beitrag anzeigen

Benutzerbild von Jelly
Jelly

Registriert seit: 11. Apr 2003
Ort: Moestroff (Luxemburg)
3.741 Beiträge
 
Delphi 2007 Professional
 
#12

Re: Uhrzeit auf die Millisekunde

  Alt 18. Mai 2007, 11:06
In der SDK hab ich folgende nützliche Funktion gefunden:
Zitat von SDK:
High-Resolution Timer

A counter is a general term used in programming to refer to an incrementing variable. Some systems include a high-resolution performance counter that provides high-resolution elapsed times.


If a high-resolution performance counter exists on the system, the QueryPerformanceFrequency function can be used to express the frequency, in counts per second. The value of the count is processor dependent. On some processors, for example, the count might be the cycle rate of the processor clock.

The QueryPerformanceCounter function retrieves the current value of the high-resolution performance counter. By calling this function at the beginning and end of a section of code, an application essentially uses the counter as a high-resolution timer. For example, suppose that QueryPerformanceFrequency indicates that the frequency of the high-resolution performance counter is 50,000 counts per second. If the application calls QueryPerformanceCounter immediately before and immediately after the section of code to be timed, the counter values might be 1500 counts and 3500 counts, respectively. These values would indicate that .04 seconds (2000 counts) elapsed while the code executed.
QueryPerformanceFrequency gibt die Frequenz an, mit der ein Counter (QueryPerformanceCounter) hochgezählt wird. Die Frequenz f ist prozessorabhängig, und 1/f gibt die Genauigkeit an. Auf meinem System ist f z.B. 3579545, und ich hab somit eine maximale Genauigkeit von 279 ns.
Mit QueryPerformanceCounter liest du den aktuellen Wert aus. Die Differenz von 2 Aufrufen gibt dir die Anzahl der Ticks an. Diesen Werte geteilt durch die Frequenz gibt dir die Differenz in Sekunden aus.
  Mit Zitat antworten Zitat