Re: How to time the execution of a method?
- From: "Maarten Wiltink" <maarten@xxxxxxxxxxxxxxxxxx>
- Date: Wed, 24 Oct 2007 14:10:40 +0200
"Nurax" <nurax@xxxxxxxxxxxxxx> wrote in message
news:ffn4s8$ltn$1@xxxxxxxxxxxxxxx
[...]
function TimeMethod(x: TMethod): string;
var i, t, tot: Cardinal;
begin
tot := 0;
for i := 1 to 1000 do
begin
t := GetTickCount;
x;
Inc(tot, GetTickCount - t);
end;
result := FormatFloat('Seconds: 0.0000', tot/1000);
end;
This solves a different problem. You measure a thousand times,
then average all the individual measurements. If the resolution
of GetTickCount is not sufficient to measure the time taken by
calling x, that won't help. The average of a thousand zeroes is
still zero.
If you want to reduce quantisation error or jitter, this is a
good way. If you want to improve resolution, call GetTickCount
exactly twice.
Groetjes,
Maarten Wiltink
.
- Follow-Ups:
- Re: How to time the execution of a method?
- From: Nurax
- Re: How to time the execution of a method?
- References:
- How to time the execution of a method?
- From: Robert Baker
- Re: How to time the execution of a method?
- From: Nurax
- How to time the execution of a method?
- Prev by Date: Re: How to time the execution of a method?
- Next by Date: Re: How to time the execution of a method?
- Previous by thread: Re: How to time the execution of a method?
- Next by thread: Re: How to time the execution of a method?
- Index(es):
Relevant Pages
|