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

Discussion in 'C++' started by Peng Yu, Mar 6, 2005.

  1. Peng Yu

    Peng Yu Guest

    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
     
    Peng Yu, Mar 6, 2005
    #1
    1. Advertising

  2. "Peng Yu" <> wrote...
    > 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
     
    Victor Bazarov, Mar 6, 2005
    #2
    1. Advertising

  3. Peng Yu

    Peng Yu Guest

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

    Peng

    On Sun, 6 Mar 2005 14:55:49 -0500, "Victor Bazarov"
    <> wrote:

    >"Peng Yu" <> wrote...
    >> 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
    >
     
    Peng Yu, Mar 7, 2005
    #3
  4. Try gprof

    Peng Yu wrote:
    > Could you give me a pointer of the better profiler that you think?
    > Thanks!
    >
    > Peng
    >
    > On Sun, 6 Mar 2005 14:55:49 -0500, "Victor Bazarov"
    > <> wrote:
    >
    > >"Peng Yu" <> wrote...
    > >> 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
    > >
     
    Raghu Uppalli, Mar 7, 2005
    #4
  5. Peng Yu wrote:
    > 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
     
    Victor Bazarov, Mar 7, 2005
    #5
  6. Peng Yu

    Peng Yu Guest

    On Mon, 07 Mar 2005 10:35:21 -0500, Victor Bazarov
    <> wrote:

    >Peng Yu wrote:
    >> 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

    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
     
    Peng Yu, Mar 8, 2005
    #6
  7. "Peng Yu" <> wrote...
    > [..]
    > 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
     
    Victor Bazarov, Mar 9, 2005
    #7
  8. Peng Yu

    Anoop Aryal Guest

    Peng Yu wrote:

    > 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
     
    Anoop Aryal, Mar 29, 2005
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Girish Sahani

    How to measure execution time of a program

    Girish Sahani, Jun 28, 2006, in forum: Python
    Replies:
    0
    Views:
    378
    Girish Sahani
    Jun 28, 2006
  2. Fredrik Lundh
    Replies:
    4
    Views:
    19,187
    Fredrik Lundh
    Jun 28, 2006
  3. Girish Sahani
    Replies:
    1
    Views:
    323
    Wolfram Kraus
    Jun 28, 2006
  4. David Brant

    Runing a external program

    David Brant, Dec 5, 2007, in forum: Java
    Replies:
    1
    Views:
    283
    Patricia Shanahan
    Dec 5, 2007
  5. Christopher Dancy
    Replies:
    3
    Views:
    114
    Christopher Dancy
    Apr 7, 2010
Loading...

Share This Page