AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Windows.GetTickCount64 auch unter Windows XP?
Thema durchsuchen
Ansicht
Themen-Optionen

Windows.GetTickCount64 auch unter Windows XP?

Ein Thema von Glados · begonnen am 11. Okt 2017 · letzter Beitrag vom 15. Jan 2018
 
Fukiszo
(Gast)

n/a Beiträge
 
#24

AW: Windows.GetTickCount64 auch unter Windows XP?

  Alt 15. Jan 2018, 21:18
ich nutz QueryPerformanceCounter immer wenn ich was benche, ich finde es sehr präzise.
Nur als vergleich gegen GetTickCount egal ob x86 oder x64.
Als alternative halt.
Ich hoffe der code ist mit neueren delphi versionen kompatibel.

Delphi-Quellcode:
{QueryPerformanceCounter uses the PC's clock counter just as GetTickCount, but it
reads the current value of the countdown register in the timer chip to gain more
accuracy -- down to 1.193MHz (about 800ns).

However, it takes 5 to 10us to call QueryPerformanceCounter, because it has to
do several port I/O instructions to read this value.

If you are running multiprocessor NT, QueryPerformanceCounter uses the Pentium
cycle counter.

You should not be using the raw value of QueryPerformanceCounter; you should
always divide by QueryPerformanceFrequency to convert to some known time base.
QueryPerformanceCounter doesn't run at the same rate on all machines.

The example below shows how to use it in Delphi 3/4:
}


type
  TInt64 = TLargeInteger;
var
  Frequency, lpPerformanceCount1, lpPerformanceCount2 : TLargeInteger;

begin
  QueryPerformanceCounter(TInt64((@lpPerformanceCount1)^));

  // activity to measure
  my_proc;

  QueryPerformanceCounter(TInt64((@lpPerformanceCount2)^));
  QueryPerformanceFrequency(TInt64((@Frequency)^));

  // this shows the time in ns
  ShowMessage(IntToStr(Round(1000000 * (lpPerformanceCount2.QuadPart -
                       lpPerformanceCount1.QuadPart) / Frequency.QuadPart)));
end;
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:38 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz