2

I have a C++ based program up and running, my problem is that I would like to know:

  • what are the top10, top5, topX methods that are called the most
  • what are the heaviest classes for computation or what threads require the maximum clock cycles

it's possible to do this with tools like valgrind, perf or similar under Linux ?

I should not that this application uses many third part libs, but I'm not interested in those since what I want to modify and improve is the core of app itself so I can cut the list of all the possible methods down to the ones implemented only by the "real application".

In general how to detect what is the class or the method responsible for the biggest failures in branching and performance loss ?

user1849534
  • 2,329
  • 4
  • 18
  • 20
  • if a function is called take note of it using a variable, then display each functions variable in the console to see which is called the most? – Syntactic Fructose Dec 15 '12 at 18:42
  • @Need4Sleep not exactly a "solution", also I want to investigate the executable, I'm not interested to manipulate the entire codebase for this app, it's big and it's a dangerous thing to do, and also, it will be a waste of time. – user1849534 Dec 15 '12 at 18:44

3 Answers3

2

You are looking for a profiler, such as gprof.

NPE
  • 486,780
  • 108
  • 951
  • 1,012
  • i have just taken a rapid look but i want to ask this, gprof only works if the app is compiled with debugging symbols ? ( `-g` flag under gcc ) there is nothing that works in any case ? – user1849534 Dec 15 '12 at 18:50
1

The program you are searching for is called a profiler. It gives you a list of methods called and which percentage of your program running time they use. If you're under Linux you can use tools like valgrind, on windows I personally use Very Sleepy. You can also see this thread for a list of profiler under Linux: thread

Community
  • 1
  • 1
Étienne
  • 4,773
  • 2
  • 33
  • 58
  • Also under MacOS/X, the included Activity Monitor utility has a mini-profiler built into it.... just click on your (already running) process in the processes list, then click the "Sample Process" button, wait a few seconds, and a report appears. – Jeremy Friesner Dec 15 '12 at 18:47
1

to calculate machine cycle for a function or depth of a calls you can use QUANTIFY tool.

Astro - Amit
  • 767
  • 3
  • 15
  • 36