Autor Beitrag
NeWsOfTzzz
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 233


D4 Prof
BeitragVerfasst: Fr 29.10.04 20:14 
ich hab gelesen dass timegettime alle 49 tage nen overflow hat? wie kann man den abfangen? wird dabei ne message geschickt?
Andreas Pfau
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 997



BeitragVerfasst: Fr 29.10.04 23:49 
Hallo,

der Overflow kommt zustande weil mit 32-Bit-Variablen gearbeitet wird die nach 49.71 Tagen eben überlaufen udnw ieder bei 0 anfangen.

Ich hab mal in der PSDK nachgeschaut und da steht nix von Messages, aber der gut gemeinte Rat für Zeitmessungen die Differenz zweier Werte zu nehmen.

Da du aber davon ausgehtn kannst dass deine Anwendung innerhlab dieser knapp 7 Wochen die Funktion zumindest ein paar mal aufrufst, könntest du den Rückgabewert in ein Int64 stecken und bei jedem Overflow (wenn der zurückgegeben Wert kleiner ist als der gespeicherte) einfach den Counter um 2^32 erhöhst.

Aber jetzt mal ne Frage: wozu brauhcst du die Funktion? Um nen Intervall zu messen empfeihlt sich der PerformanceCounter. Aber wenn du die Differenz zweier Intervalle von timegettime nimmst geht das auch, musst hat den overflow wrappen...

_________________
Life is a bad adventure, but the graphic is really good!
blackbirdXXX

ontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1077
Erhaltene Danke: 1

Ubuntu Dapper

BeitragVerfasst: Sa 30.10.04 00:15 
Ich glaube bei QueryPerformanceCounter entfällt dieses Limit.

_________________
Klein, schwarz und ärgert Techniker? Jumper!
Andreas Pfau
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 997



BeitragVerfasst: Sa 30.10.04 00:35 
Hallo,

der PerformanceCoutner ist Systemabhängig. Meiner tick mit 3,6MHz. Das wäre dann ein Overflow nach 81706 Jahren (da ich ja ne 64bit Variable habe)... Bis dahin wird es keine Komputer mehr geben *g*

Zumindest sind die 81tausendjahre mal so rausgekommen, hier der Code:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
var
  F: Int64;
begin
  QueryPerformanceFrequency(F);
  Edit1.Text := Format('%d %.0f', [F, (High(Int64) / F) / (86400 * 365)]);

Und der Rückgabewert: "3579545 81706"
Müsste stimmen, oder?

Auf jeden Fall heißt es dass der PerformanceCounter nicht auf jedem System verfügbar sei oder so aber das hat mich bisher nicht davon abhalten können ihn zu benutzen. Ich habe bisher noch nie so was gelesen wie "mein Computer kann das net" oder so.

_________________
Life is a bad adventure, but the graphic is really good!
NeWsOfTzzz Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 233


D4 Prof
BeitragVerfasst: Sa 30.10.04 00:49 
Eigentlich wollte ich ja aus reiner Kompatibilität timegettime (zusätzlich) einbauen :)
Andreas Pfau
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 997



BeitragVerfasst: Sa 30.10.04 17:01 
Hallo,

Du kannst auch GetSystemTimeAsFileTime() nehmen, liefert 2 32-Bit Integer die du zu nem Int64 verbinden kannst.

Auflösung max. 100ns, ich weiß aber net ob die Funktion selbst auch so präzise ist, müsste man mal probieren.

_________________
Life is a bad adventure, but the graphic is really good!