Solved

How to check the time of procedure execution?

Posted on 2001-07-27
5
203 Views
Last Modified: 2010-04-06
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.
0
Comment
Question by:Skorup
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6326095
start := GetTickCount;
Call_procedure;
ende := GetTickCount;
timeusage := ende-start; //in milliseconds
0
 

Accepted Solution

by:
d32coder earned 50 total points
ID: 6326159
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
 

Expert Comment

by:d32coder
ID: 6326164
Oops.

Forget the FormatDateTime reference in the previous comment.
0
 

Expert Comment

by:d32coder
ID: 6326168
Crap  :)

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

I need more sleep.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6335187
:-(
not a good choice,
gettickcount is much more correct,
because it has not so an overhead as the time-function
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month4 days, 15 hours left to enroll

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question