How to check the time of procedure execution?

How can I check the amount of time taken by a procedure. I look for a timer which could count the time during procedure execution. Maybe somebody have an assembler code to system timer interrupt, cause it could solve this problem.
SkorupAsked:
Who is Participating?
 
d32coderCommented:
using the formatdatetime() procedure at the start and end of the procedure can give you the elapsed time.

uses DateUtils,


procedure MyCode(sender: TObject);
var X,Y: TTime; Z: Integer;
begin
 x := Time;


 your code here



 y := Time;
 a := SecondsBetween(x,y);
 Label1.Caption := IntToStr(a) + ' Seconds elapsed.';
end;
 

Note: There is also a MilliSecondsBetween, used the same way;


Good Luck
Don
0
 
kretzschmarCommented:
start := GetTickCount;
Call_procedure;
ende := GetTickCount;
timeusage := ende-start; //in milliseconds
0
 
d32coderCommented:
Oops.

Forget the FormatDateTime reference in the previous comment.
0
 
d32coderCommented:
Crap  :)

Change Z: Integer to A: Integer;
in the var line.  

I need more sleep.
0
 
kretzschmarCommented:
:-(
not a good choice,
gettickcount is much more correct,
because it has not so an overhead as the time-function
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.