any classes help me to measure some program segment runing time.

P

Peng Yu

Hi,

For example, there is a function which is called many times from
different places in a program. I want measure how long this function
runs in total.

Of course, I can use gettimeofday to measure its running time. But it
looks a little cumbersome. I'm wondering whether there is a class for
it. Thanks!

Best wishes,
Peng
 
V

Victor Bazarov

Peng Yu said:
For example, there is a function which is called many times from
different places in a program. I want measure how long this function
runs in total.

Of course, I can use gettimeofday to measure its running time. But it
looks a little cumbersome. I'm wondering whether there is a class for
it. Thanks!

There is no class for it. There are tools for that. Called "profilers".

V
 
P

Peng Yu

Could you give me a pointer of the better profiler that you think?
Thanks!

Peng
 
V

Victor Bazarov

Peng said:
Could you give me a pointer of the better profiler that you think?

Please don't top-post. Thanks.

Try Intel's vTune, it's pretty good and exists on several platforms.
However, this is still very platform-specific, so please make all
your tool inquiries in a newsgroup dedicated to your platform.

V
 
P

Peng Yu

Please don't top-post. Thanks.

Try Intel's vTune, it's pretty good and exists on several platforms.
However, this is still very platform-specific, so please make all
your tool inquiries in a newsgroup dedicated to your platform.

V
By "top-post", do you mean that I should put the reply under the
original message like this.

Is it a general courtesy fot newsgroup? Cause I use the reverse way to
reply email.

Thanks,
Peng
 
V

Victor Bazarov

Peng Yu said:
[..]
By "top-post", do you mean that I should put the reply under the
original message like this.

It would be appreciated, yes.
Is it a general courtesy fot newsgroup?

Yes. It promotes readability.
Cause I use the reverse way to
reply email.

I don't.

Microsoft tools spread bad habits around the world. Just for that
the designers of their software should be hung, shot, and drowned.

V
 
A

Anoop Aryal

Peng said:
For example, there is a function which is called many times from
different places in a program. I want measure how long this function
runs in total.

i would use a profiler to do what you are describing. profilers can give you
the time spent on each function regardless of where it was called from.

since profilers are rather specific to the compiler/platform you use, it's a
worthless exercise to give generic advice. i use gcc on GNU/Linux systems
and use gprof for profiling (callgrind is also a nice alternative). i have
no idea of comparable tools in other platforms as i have not seriously used
other platforms for development in a long time.

if you do use GNU/Linux (or gcc on any platform), email me directly and i
can give you pointers if you need.

anoop aryal
 

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,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top