What's your favorite profiling tool (for C++)


So far, I've only used Rational Quantify. I've heard great things about Intel's VTune, but have never tried it!

Edit: I'm mostly looking for software that will instrument the code, as I guess that's about the only way to get very fine results.

See also:

What are some good profilers for native C++ on Windows?

6/20/2020 9:12:55 AM

For Linux: Google Perftools

  • Faster than valgrind (yet, not so fine grained)
  • Does not need code instrumentation
  • Nice graphical output (--> kcachegrind)
  • Does memory-profiling, cpu-profiling, leak-checking

IMHO, sampling using a debugger is the best method. All you need is an IDE or debugger that lets you halt the program. It nails your performance problems before you even get the profiler installed.


My only experience profiling C++ code is with AQTime by AutomatedQA (now SmartBear Software). It has several types of profilers built in (performance, memory, Windows handles, exception tracing, static analysis, etc.), and instruments the code to get the results.

I enjoyed using it - it was always fun to find those spots where a small change in code could make a dramatic improvement in performance.


I have never done profiling before. Yesterday I programmed a ProfilingTimer class with a static timetable (a map<std::string, long long>) for time storage.

The constructor stores the starting tick, and the destructor calculates the elapsed time and adds it to the map:

ProfilingTimer::ProfilingTimer(std::string name)
 : mLocalName(name)
 sNestedName += mLocalName;
 sNestedName += " > ";

 if(sTimetable.find(sNestedName) == sTimetable.end())
  sTimetable[sNestedName] = 0;

 mStartTick = Platform::GetTimerTicks();

 long long totalTicks = Platform::GetTimerTicks() - mStartTick;

 sTimetable[sNestedName] += totalTicks;

 sNestedName.erase(sNestedName.length() - mLocalName.length() - 3);

In every function (or {block}) that I want to profile i need to add:

ProfilingTimer _ProfilingTimer("identifier");

This line is a bit cumbersome to add in all functions I want to profile since I have to guess which functions take a lot of time. But it works well and the print function shows time consumed in %.

(Is anyone else working with any similar "home-made profiling"? Or is it just stupid? But it's fun! Does anyone have improvement suggestions?

Is there some sort of auto-adding a line to all functions?)


I've used Glowcode extensively in the past and have had nothing but positive experiences with it. Its Visual Studio integration is really nice, and it is the most efficient/intuitive profiler that I've ever used (even compared to profilers for managed code).

Obviously, thats useless if your not running on Windows, but the question leaves it unclear to me exactly what your requirements are.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Email: [email protected]