performance of c++ programm

C

CQ

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.
 
A

Alf P. Steinbach

* 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.
 
R

Rolf Magnus

CQ said:
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.
 
P

Puppet_Sock

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
 
W

Walter Bright

CQ said:
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
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top