performance of c++ programm

Discussion in 'C++' started by CQ, Nov 22, 2005.

  1. CQ

    CQ Guest

    Hi ya all!

    I would like to check the performance of my c++ programm. That is, I
    would like to find out which functions are the most time consuming
    ones, for instance. Then I would like to figure out if the program has
    some memory leaks.

    Well, I have heard that there is a way to do that. But I have no idea
    how it goes.


    Can anyone help me on that?


    Thanks a lot in advance,

    CQ.
    CQ, Nov 22, 2005
    #1
    1. Advertising

  2. * CQ:
    >
    > I would like to check the performance of my c++ programm. That is, I
    > would like to find out which functions are the most time consuming
    > ones, for instance.


    Check out profiler tools (note that tool usage is generally OT here).


    > Then I would like to figure out if the program has some memory leaks.


    That would be a good idea to check first. But instead of making a mess
    and then try to tidy it up, it's generally better (much less work, much
    better chance at acceptable result) to be orderly in the first place.
    In C++, for this particular issue, it generally means using smart
    pointers and standard library container classes, instead of raw
    pointers, raw arrays and DIY containers.


    > Well, I have heard that there is a way to do that. But I have no idea
    > how it goes.
    >
    > Can anyone help me on that?


    See above.

    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is it such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
    Alf P. Steinbach, Nov 22, 2005
    #2
    1. Advertising

  3. CQ

    Rolf Magnus Guest

    CQ wrote:

    > Hi ya all!
    >
    > I would like to check the performance of my c++ programm. That is, I
    > would like to find out which functions are the most time consuming
    > ones, for instance. Then I would like to figure out if the program has
    > some memory leaks.
    >
    > Well, I have heard that there is a way to do that. But I have no idea
    > how it goes.


    For both, there are pwerful development tools. The time measurement is done
    by a profiler. Memory leaks can be found with a memory debugger. If you are
    developing for linux, have a look at valgrind, which is free and can do
    both.
    Rolf Magnus, Nov 22, 2005
    #3
  4. CQ

    Puppet_Sock Guest

    CQ wrote:
    [snips]
    > I would like to check the performance of my c++ programm. That is, I
    > would like to find out which functions are the most time consuming
    > ones, for instance. Then I would like to figure out if the program has
    > some memory leaks.


    As others have said, there are various commercial profiler tools.

    A limited form of memory leak detection is standard on some
    development platforms.

    As to profiling: The basic idea is, the tool will "instrument" your
    code. That is, it will insert extra lines of code that do things
    like marking the call to and return from various functions, and
    things like that. You can "roll your own" to get some idea of
    the time your code spends in various activities. For example,
    at a very simple level you could use the system command
    and grab your operating system's time before you start a task
    and after you finish. This will be not nearly as sophisticated
    as a commercial product.
    Socks
    Puppet_Sock, Nov 22, 2005
    #4
  5. "CQ" <> wrote in message
    news:...
    > I would like to check the performance of my c++ programm. That is, I
    > would like to find out which functions are the most time consuming
    > ones, for instance. Then I would like to figure out if the program has
    > some memory leaks.
    >
    > Well, I have heard that there is a way to do that. But I have no idea
    > how it goes.


    This should get you started: www.digitalmars.com/techtips/timing_code.html

    -Walter Bright
    www.digitalmars.com C, C++, D programming language compilers
    Walter Bright, Nov 23, 2005
    #5
    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. Freddy Fischer
    Replies:
    1
    Views:
    288
    Natty Gur
    Oct 23, 2003
  2. AlexPain

    Java Programm into Systray

    AlexPain, Jul 30, 2003, in forum: Java
    Replies:
    5
    Views:
    1,465
    Eugene Toporov
    Aug 5, 2003
  3. Romeo
    Replies:
    3
    Views:
    348
    Mickey Segal
    Nov 13, 2003
  4. Excluded_Middle

    Sheck this simple programm

    Excluded_Middle, Jul 13, 2004, in forum: Java
    Replies:
    7
    Views:
    412
    Roedy Green
    Jul 14, 2004
  5. Sam
    Replies:
    1
    Views:
    479
    Andrew Thompson
    Nov 10, 2004
Loading...

Share This Page