On Sep 19, 9:51 am, developer28 <aman.k.se...@gmail.comwrote:
On Sep 19, 1:58 am, Scott Gifford <sgiff...@suspectclass.comwrote:
developer28 <aman.k.se...@gmail.comwrites:
[...]
What i basically want is a tool that can answer some questions like:
Which of the following loops is faster?
[...]
Time taken to execute a virtual function call compared to an ordinary
function call?
For particular microbenchmarks like this, I often write two small
programs using the two techniques, then use the Unix "time" program to
compare how long they took to complete, how much CPU time they used,
etc.
The real problem is eliminating optimization. If the compiler
detects that your loop does nothing, it eliminates it. I use a
special test harness to (try to) avoid this; the actions to be
measured are in a virtual function (which tends to stop the
optimizer, since it cannot determine at the call site which
function is being called), and ensure that all of the operations
in the virtual function affect a value which I store in a member
variable before returning. This seems to be sufficient with the
compilers I currently have access to.
I also use the standard function clock(), rather than the
external function time. From what I've been able to see,
however, this function doesn't work correctly in VC++. (It's
suppose to return the CPU time used; in VC++, my impression is
that it returns wall clock time used.)
For finding the actual performance bottlenecks in an application, I
use gprof.
Intel also has some performance tools that look interesting, but
they're not free and I haven't tried them yet.
Thanks for the reply and for taking the patience to answer.
But my problem is that i am on a windows XP system so won't be able to
use unix related tools for the same.
Why not? The "time" command is a built-in function in bash and
in ksh---both are readily available for Windows. Gprof is also
available for Windows, but your compiler likely includes
something as well, that is tuned for your compiler. (Gprof
needs some help from the compiler.)
--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34