idiot Posted November 28, 2011 Share Posted November 28, 2011 I was experimenting with GetSystemTime and found that system timer increases in increments of 15-16 ms while each time quantum lets you do a lot of computing, you are restricted to these quantization, I found this when I was trying to split a process in 20 ms intervals my question is if there is a way to change it and how I can change it If this quantization comes from computer hardware that is fine I just want to know program PrintSystemTime; var n: Integer; begin for n:= 1 to 100 do Writeln(IntToStr(GetSystemTime)); end. Quote Link to comment Share on other sites More sharing options...
FHannes Posted November 28, 2011 Share Posted November 28, 2011 Not sure, GetSystemTime uses the GetTickCount Win32 API. Quote Link to comment Share on other sites More sharing options...
Wanted Posted November 28, 2011 Share Posted November 28, 2011 Nielsie95 once posted this somewhere program New; function QueryPerformanceFrequency(out Frequency: Int64): LongBool; external 'QueryPerformanceFrequency@kernel32.dll stdcall'; function QueryPerformanceCounter(out Counter: Int64): LongBool; external 'QueryPerformanceCounter@kernel32.dll stdcall'; procedure MarkTime(var Time: Int64); var Freq: Int64; begin if QueryPerformanceFrequency(Freq) then QueryPerformanceCounter(Time) else Time := GetTickCount; end; function TimeFromMark(Mark: Int64): Double; var Freq, Now: Int64; begin if QueryPerformanceFrequency(Freq) then begin QueryPerformanceCounter(Now); Result := ((Now - Mark) / Freq) * 1000; end else Result := (GetTickCount - Mark); end; var Time: Int64; begin MarkTime(Time); WriteLn('Straight from MarkTime took ' + FloatToStr(TimeFromMark(Time)) + ' ms.'); Wait(10); WriteLn('After another Wait(10) we are ' + FloatToStr(TimeFromMark(Time)) + ' ms away from the mark.'); end. Quote Link to comment Share on other sites More sharing options...
idiot Posted November 28, 2011 Author Share Posted November 28, 2011 GetTickCount and GetSystemTime return the same value thank you, I ll go to the next step now ---------- Post added at 12:39 AM ---------- Previous post was at 12:32 AM ---------- Nielsie95 once posted this somewhere program New; function QueryPerformanceFrequency(out Frequency: Int64): LongBool; external 'QueryPerformanceFrequency@kernel32.dll stdcall'; function QueryPerformanceCounter(out Counter: Int64): LongBool; external 'QueryPerformanceCounter@kernel32.dll stdcall'; procedure MarkTime(var Time: Int64); var Freq: Int64; begin if QueryPerformanceFrequency(Freq) then QueryPerformanceCounter(Time) else Time := GetTickCount; end; function TimeFromMark(Mark: Int64): Double; var Freq, Now: Int64; begin if QueryPerformanceFrequency(Freq) then begin QueryPerformanceCounter(Now); Result := ((Now - Mark) / Freq) * 1000; end else Result := (GetTickCount - Mark); end; var Time: Int64; begin MarkTime(Time); WriteLn('Straight from MarkTime took ' + FloatToStr(TimeFromMark(Time)) + ' ms.'); Wait(10); WriteLn('After another Wait(10) we are ' + FloatToStr(TimeFromMark(Time)) + ' ms away from the mark.'); end. I can't compile it, Scar says semicolon missing in line 4 and I do not know what to change Quote Link to comment Share on other sites More sharing options...
Wanted Posted November 28, 2011 Share Posted November 28, 2011 GetTickCount and GetSystemTime return the same value thank you, I ll go to the next step now ---------- Post added at 12:39 AM ---------- Previous post was at 12:32 AM ---------- I can't compile it, Scar says semicolon missing in line 4 and I do not know what to change You must enable API calls, not sure if you still can in SCAR. Quote Link to comment Share on other sites More sharing options...
FHannes Posted November 28, 2011 Share Posted November 28, 2011 You must enable API calls, not sure if you still can in SCAR. It's in the options dialog. Quote Link to comment Share on other sites More sharing options...
idiot Posted November 28, 2011 Author Share Posted November 28, 2011 thank you very much now everything working, and getting time with great precision Quote Link to comment Share on other sites More sharing options...
Wanted Posted November 28, 2011 Share Posted November 28, 2011 thank you very much now everything working, and getting time with great precision That's good to hear. Quote Link to comment Share on other sites More sharing options...