Take millisecond time precision (method i):
Var
T1,t2:int64;
R1:int64;
Begin
t1:=gettickcount;//get start Count WINDOWS API
Sleep (1000); {do ...} Execute the code to be timed
t2:=gettickcount;//Get End Count value
r1:=t2-t1;//get time, Y ' Guo 4~ (}.u_%t "HV unit millisecond (ms)
ShowMessage (IntToStr (R1));
End
Take millisecond time precision (method two):
Use dateutils;//Reference dateutils unit
Var
T1,t2:tdatetime;
R1:int64;
Begin
T1:=now ()//Get Start timer time
Sleep (1000); {do ...} Execute the code to be timed
T2:=now ()//Get End Timer
R1:=secondsbetween (T2,T1)//Get time, d6k=+w TSOUBP fertility _ii unit seconds (s)
R1:=millisecondsbetween (T2,T1)//timing time,
Ftvggu8e36
Unit Millisecond (MS)
ShowMessage (IntToStr (R1));
End
Note: The above two methods are tested by me as if they can only produce 0.01 seconds of timing accuracy.
Take system-level time precision:
Var
C1:int64;
T1,t2:int64;
r1:double;
Begin
QueryPerformanceFrequency (C1);//windows API return Count Frequency (intel86:1193180) (Gets the number of times the system's high-performance frequency counter vibrates within a millisecond)
QueryPerformanceCounter (t1);//windows API get Start meter value
Sleep (1000); {do ...} Execute the code to be timed
QueryPerformanceCounter (T2)//Get End Count value
r1:= (T2-T1)/c1;//gets the time of the timer,
L ':(yo piece}^k (fertile * Soft {Ux
j5^ gz, 1a6t. " 1) Ti
X@t) AC W Teaching
Yjtt]$1ucqs ' E) net 7g per second (s)
r1:= (T2-T1)/c1*1000;//get time, in milliseconds (ms)
r1:= (T2-T1)/c1*1000000;//gets the time of the timer, unit microseconds
ShowMessage (FLOATTOSTR (R1));
End