Performance measurement of a single method

A

Andreas Göbel

Hi all,
I'm looking for an approach to simply measure the performance (time
consumption in milliseconds) of a single method call. I already tried to use
the windows system time (sys/timeb.h) for that but the accuracy of the
result is too low (moves between 0 and 10 milliseconds). Is there any
possibility to measure more precises without using an external (costly)
profiler or does anybody know a free profiler on windows?

Regards
 
A

Amal P

Hi,
You can surely use QuerryPerfornanceTimer or you can do it by using
rdtsc. rdtsc is an instruction that reads the timestamp in pentium 4.
Please refer Intel Instruction set reference manuals for this.Querry
performance timer can be very easly used. It can give in allmost 1ms
resolution.

Best Regards,
Amal P.
 
J

Jakob Bieling

Andreas Göbel said:
Hi all,
I'm looking for an approach to simply measure the performance (time
consumption in milliseconds) of a single method call. I already tried
to use the windows system time (sys/timeb.h) for that but the
accuracy of the result is too low (moves between 0 and 10
milliseconds). Is there any possibility to measure more precises
without using an external (costly) profiler or does anybody know a
free profiler on windows?

Instead of measuring the time it takes to execute the functions
once, you could measure the time it takes to execute the function
1,000,000 times. Or 4,000,000, depending on how expensive your function
is.

If we are talking about tiny functions, then the loop could have
undesired relative impact on the timing. In that case I suggest you take
a look at the assembly, strop the function call (or inlined function
code) from it and measure the time it takes to execute the empty loop.

hth
 
P

Phlip

Andreas said:
I'm looking for an approach to simply measure the performance (time
consumption in milliseconds) of a single method call. I already tried to
use
the windows system time (sys/timeb.h) for that but the accuracy of the
result is too low (moves between 0 and 10 milliseconds). Is there any
possibility to measure more precises without using an external (costly)
profiler or does anybody know a free profiler on windows?

Write a test case (you do _have_ unit tests, don't you?) that calls the
function one zillion times. Time the test case. Time it again with the
function commented out.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top