Home > Back-end >  Delphi in milliseconds
Delphi in milliseconds

Time:09-24

In the program, I use a
T1:=GetTickCount;
T2:=GetTickCount;
R1:=t2 - t1;
Also use a timer to time, to control the 5 seconds, press a button, timing, but from the beginning to the end of the five seconds to record the time of more than 5000 milliseconds, is this why?

CodePudding user response:

Didn't quite understand what you want to express, paste the code in the ontimer

CodePudding user response:

The Timer will not.
Timer is every Interval time sends a WM_Timer message. The message in the message queue queue, one by one, WM_Timer message is processing time depends on how much the previous message, the duration of each message processing.

CodePudding user response:

System ticking time is accurate, the key is the timer is not the name accurate, it is not possible then why is equal to 5000 ms

CodePudding user response:

Starttime: now=();
Stoptime: Now=();
R1:=MilliSecondsBetween (stoptime, starttime);//timing time, unit milliseconds (ms)
StatusBar1. Panels. The Items [2]. Text:='this query takes: + inttostr (r1) +' ms';

CodePudding user response:

Upstairs method is good, mark

CodePudding user response:

1) the GetTickCount even if precision is not enough,
2) the accuracy of the timer timer is not enough,
3) more than 5000 milliseconds, is normal, just a small percentage of=5000, not enough time will not end, is only most of the time, are more than 5000 milliseconds,

CodePudding user response:

Using multimedia timer timesetevent, millisecond precision can be obtained

CodePudding user response:

System clock timing is about 18.2 per second 1000/18.2 of about 55 ms namely the timing interval timer is about 55 ms, again a little bit small, it's just timing continuously for several times, can not use timer precise timing,
TimeGetTime can be accurate to milliseconds, more precise time will be in the driver,

And precise calculation time interval, is more troublesome, need about RTSC instruction,
Or
BOOL QueryPerformanceCounter (
LARGE_INTEGER * lpPerformanceCount//pointer to counter value
);

BOOL QueryPerformanceCounter (
LARGE_INTEGER * lpPerformanceCount//pointer to counter value
);
Functions, such as

CodePudding user response:

http://www.cnblogs.com/sifenkesi/archive/2011/06/01/2065673.html
You can consult

CodePudding user response:

 
USES Windows;

Var
I1, i2: Int64;
The diff, cc: Int64;
B: Boolean;
The begin
The QueryPerformanceCounter (i1);
.
.
The QueryPerformanceCounter (i2);
The diff:=i2 - i1;
B:=QueryPerformanceFrequency (cc);//WINDOWS API return counting frequency (Intel86:1193180) high performance frequency counter (acquired within a millisecond of vibration frequency)
If not then cc: b=1;//false said does not support high performance timer
Result:=Round (diff * 1000/cc);//ms
end;

CodePudding user response:

Please use the multi-media timer, the PC can reach 1 ms level in time

CodePudding user response:

Label3. Caption:=FormatFloat (' 0 ', (AWorkCount - lastc)/MilliSecondsBetween (now, lastt)) + 'KB/s';
SProgressBar2. Position:=AWorkCount;
Lastc:=AWorkCount;//ProgressBar1. Position lastc can
//smemo1. Lines. The Add (MilliSecondsBetween (now, lastt). The ToString ());
Lastt:=now;

CodePudding user response:

2013 posts...
  • Related