Simon Sander <simon....@uni-mb.si> wrote in article
<3432DF11...@uni-mb.si>...
> Hi?
>
> How can I mesure time with milisecond precision.
>
> For example I have an algorithm, and i want to mesure it's execution
> time.
>
> It would be nice something like this:
>
> t1:=TimerStart;
>
> for i:=1 to 10000 Do something
>
> t2:=TimerStop;
>
> time:=t2-t1;
>
> Thanks!
>
>
The Windows API call GetTickCount returns the precision
you want -- milliseconds. GetTickCount returns a
4-byte integer (LongInt in Delphi 1, could use just
Integer in Delphi 3).
efg
_________________________________________________
Earl F. Glynn Earl...@WorldNet.att.net
MedTech Research Corporation
Lenexa, KS 66219 USA
>How can I mesure time with milisecond precision.
>
>
GetTickCount is OK if you want millisecond resolution
For example
Assuming truncation
Start time = 10.8 ticks GetTickCount returns 10
EndTime = 15.2 ticks GetTickCount returns 15
Time elapsed 4.4, time calculated 5
Assuming Rounding
Start time = 10.4 ticks GetTickCount returns 10
EndTime = 15.6 ticks GetTickCount returns 16
Time elapsed 5.1, time calculated 6
. . . but if you want millisecond precision the attached function would do
it, resolution is approx 1 microsecond, precision is approx 3 microseconds.
The function VTD_GetTime returns the number of seconds as a double.
unit VTimerDv;
{by Richard Holmes from Delphi Informant Sept 1995}
interface
function VTD_GetTime : double;
implementation
var
wVTDSegment : word;
wVTDOffset : word;
aVTDTicks : array [1..2] of longint;
dSecondsPerTick: double;
procedure VTD_GetEntryPoint;
begin
asm
mov ax,$1684
mov bx,$05
xor di,di
mov es,di
int $2F
mov wVTDSegment,es
mov wVTDOffset,di
end;
end;
function VTD_GetTime : double;
begin;
asm
mov dx,wVTDSegment
mov ax, wVTDOffset
push cs
mov bx,offset @RetSpot
push bx
push dx
push ax
mov ax,$100
retf
@RetSpot:
nop
end;
inline
(
$66/
$89/$06/>aVTDTicks/
$66/
$89/$16/>aVTDTicks+4/
$DF/$2E/>aVTDTicks
);
asm
fmul dSecondsPerTick
fstp @result
end;
end;
initialization
VTD_GetEntryPoint;
dSecondsPerTick := 0.836E-6;
end.
end.
>Hi?
>
>How can I mesure time with milisecond precision.
>
>For example I have an algorithm, and i want to mesure it's execution
>time.
>
>It would be nice something like this:
>
>t1:=TimerStart;
>
>for i:=1 to 10000 Do something
>
>t2:=TimerStop;
>
>time:=t2-t1;
A somewhat crude way to do this is to use the Win API function
GetTickCount which returns the number of milliseconds since Windows
was started. Replace TimerStart and TimerStop with GetTickCount in
your example above.
---------------------
Al Testani
a...@emi.net
Boca Raton, FL
---------------------
If you need a hi-resolution timer, email me. I had one once and should be
able to find it.
--
greetings,
Peter Tiemann
Check out the localizing component TMultiLang..
http://www.preview.org/
Simon Sander wrote in message <3432DF11...@uni-mb.si>...
>Hi?
>
>How can I mesure time with milisecond precision.
>
>For example I have an algorithm, and i want to mesure it's execution
>time.
>
>It would be nice something like this:
>
>t1:=TimerStart;
>
>for i:=1 to 10000 Do something
>
>t2:=TimerStop;
>
>time:=t2-t1;
>
>Thanks!
>
In article <3438f5f4...@news.emi.net>, Al Testani <a...@emi.net>
writes
>Simon Sander <simon....@uni-mb.si> wrote:
>
>>Hi?
>>
>>How can I mesure time with milisecond precision.
>>
>>For example I have an algorithm, and i want to mesure it's execution
>>time.
>>
>>It would be nice something like this:
>>
>>t1:=TimerStart;
>>
>>for i:=1 to 10000 Do something
>>
>>t2:=TimerStop;
>>
>>time:=t2-t1;
>
>A somewhat crude way to do this is to use the Win API function
>GetTickCount which returns the number of milliseconds since Windows
>was started. Replace TimerStart and TimerStop with GetTickCount in
>your example above.
>
>---------------------
>Al Testani
>
>a...@emi.net
>Boca Raton, FL
>---------------------
>
>
--
David H. Bolton
I've just fallen in love - with an email. Now Concentrate....
This message has not been tested on any live animal before posting.
Emails formulated and controlled by laboratoire Bolton