Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
idiot

system time quantization

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
thank you very much

 

now everything working, and getting time with great precision

 

That's good to hear.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...