Re: How to time the execution of a method?



In comp.lang.pascal.delphi.misc message <471efae3$0$235$e4fe514c@xxxxxxx
4all.nl>, Wed, 24 Oct 2007 09:57:11, Maarten Wiltink
<maarten@xxxxxxxxxxxxxxxxxx> posted:
"Robert Baker" <korax1214@xxxxxxxxx> wrote in message
news:ffrsh31jdatffuit1eqd78socd3s6pa6e3@xxxxxxxxxx

function TimeMethod(x: TMethod): TDateTime;
var s,e: TDateTime;
begin
s:=Now;
x;
e:=Now;
TimeMethod:=86400*(e-s);
end;

ta:=TimeMethod(DrawA);
tb:=TimeMethod(DrawB);
tc:=TimeMethod(DrawC);


However, if
you start with a TDateTime and multiply it by 86,400, you no longer
have a TDateTime.

The difference of two TDateTimes is not a TDateTime; it is a Double of
24-hour Days (though a variable type TDateTime will accommodate it). So
he's not multiplying a TDateTime by a number.

Consider subtracting today noon from tomorrow noon. The result is one
day (do it before Saturday); it is not 1899-12-31.

However, the return value should be a Double, not a TDateTime.

A better language could use different names for ordinal and cardinal
types (the existing use of "cardinal" for a type is a blunder).

<URL:http://www.merlyn.demon.co.uk/othrlang.htm#CO>

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6.
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
.



Relevant Pages