Link to home
Start Free TrialLog in
Avatar of eNarc
eNarcFlag for United Kingdom of Great Britain and Northern Ireland

asked on

how many Runs a second?

Hi I'd like to know how many Runs a second the function will do.


you know when you see these programs exporting data from the database, it tells you how many entrys are being exported per second, is there a way of doing this? with a function?
Avatar of ahalya
ahalya
Flag of Canada image

Use a timer based on QuryPerformanceCounter to time the function.  


var start, finish : int64;

QueryPerformanceCounter(start)
//call your function
QueryPerformanceCounter(finish);

delta := finish - start


ASKER CERTIFIED SOLUTION
Avatar of ahalya
ahalya
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

var t:TDateTime;
begin
t:=now;
showmessage('some function');
t:=t-now;
caption:=FormatDateTime('hh:mm:ss(zzz)',t);
...

Open in new window

wd123:

Your solution is accurate to about 50 milliseconds, (and most functions would not take that long to execute, and you may end zero time of execution) (Timer updates about 19 times per second, so "now" is limited by that).

The solution using PerformanceCounters has a much higher accuracy level. At least about a third of a micro second in all computers, and even better in most computers.

i know it.
Good, Thanks.  

In such a case, please point it out when you post your solution in the future (especially when another suggestion that is way better than the one your are posting is already up there).

If you're trying to make the performance better, you can use a profiling tool such as AQ Time. You can run your application through AQ Time, and it reads all the procedures/functions called in the process. It gives you statistics about how many times they are called, how much time it is needed to complete the procedure (relative). The timing you'll get is relative, meaning that it takes time to notice the statistics so your process will run slower than usual. The timing on AQ time is relative to each other; in that way you will be able to see which procedure formed the bottle neck to the whole process.

If you need this for your work, you can ask the company to purchase one
http://www.automatedqa.com/products/aqtime/
It's worth the investation.