Programming C# C++ (7) Delphi (617) .NET (2) Database (71) Delphi IDE (89) Network (39) Printing (3) Strings (12) VCL (83) Windows with Delphi (280) Java (8) JavaScript (31) perl (9) php (4) VBScript (1) Visual Basic (1)
Exchange Links About this site Links to us 
|
Measure execution time in your program
3 comments. Current rating: (2 votes). Leave comments and/ or rate it.
Simply call
- StartClock before and
- StopClock after
the part of the program you want to clock, as shown in the example:
 | |  | | var
hr, mins, se, s1 : word;
procedure StartClock;
begin
GetTime (hr,mins,se,s1);
end;
procedure StopClock;
var
siz : longint;
hr2, min2, se2 : word;
begin
GetTime (hr2, min2, se2, s1);
siz := se2-se+(min2-mins)*60+(hr2-hr)*60*60;
ShowMessage (IntToStr(siz) + ' seconds');
end;
begin
StartClock;
for i := 1 to 100 do
MyProcedure(i);
StopClock;
end.
| |  | |  |
Comments:
|
anonymous from Poland
|
 |
|
|
It doesn't work :( I tried it in Delphi 2007 and errors occure :(
|
|
Alexandar from Macedonia
|
 |
|
|
It works for Pascal 0.7
I just changed this line
ShowMessage (IntToStr(siz) + ' seconds');
is changed into
writeln(siz,' seconds');
|
|
anonymous from Finland
|
|
|
|
Works easily. Might need to make few changes to the code depending of the delphi/pascal version but that should not be any problem to any experienced coder.
|
|