<p>So far, I've only used Rational Quantify. I've heard great things about Intel's VTune, but have never tried it!</p>
<p>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.</p>
<hr />
<h3>See also:</h3>
<p><a href="https://stackoverflow.com/questions/153559/what-are-some-good-profilers-for-native-c-on-windows">What are some good profilers for native C++ on Windows?</a></p>

[{'answer_id': 26668, 'author': 'Louis Brandy', 'author_id': 2089740, 'author_profile': 'https://Stackoverflow.com/users/2089740', 'pm_score': 2, 'selected': False, 'text': '<p>There are different requirements for profiling. Is instrumented code ok, or do you need to profile optimized code (or even already compiled code)? Do you need line-by-line profile information? Which OS are you running? Do you need to profile shared libraries as well? What about trace into system calls?</p>\n\n<p>Personally, I use oprofile for everything I do, but that might not be the best choice in every case. Vtune and Shark are both excellent as well.</p>\n'}, {'answer_id': 26682, 'author': 'Matt Dillard', 'author_id': 863, 'author_profile': 'https://Stackoverflow.com/users/863', 'pm_score': 3, 'selected': False, 'text': '<p>My only experience profiling C++ code is with <a href="http://www.automatedqa.com/products/aqtime/" rel="nofollow noreferrer">AQTime</a> 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.</p>\n\n<p>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.</p>\n'}, {'answer_id': 26686, 'author': 'jsight', 'author_id': 1432, 'author_profile': 'https://Stackoverflow.com/users/1432', 'pm_score': 3, 'selected': False, 'text': '<p>I\'ve used <a href="http://www.glowcode.com/summary1_gc.htm" rel="noreferrer">Glowcode</a> 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).  </p>\n\n<p>Obviously, thats useless if your not running on Windows, but the question leaves it unclear to me exactly what your requirements are.</p>\n'}, {'answer_id': 26696, 'author': 'Al.', 'author_id': 2881, 'author_profile': 'https://Stackoverflow.com/users/2881', 'pm_score': 5, 'selected': False, 'text': '<p>For linux development (although some of these tools might work on other platforms). These are the two big names I know of, there\'s plenty of other smaller ones that haven\'t seen active development in a while.</p>\n\n<ul>\n<li><a href="http://valgrind.org/" rel="noreferrer">Valgrind</a></li>\n<li><a href="http://www.cs.uoregon.edu/research/tau/home.php" rel="noreferrer">TAU - Tuning and Analysis Utilities</a></li>\n</ul>\n'}, {'answer_id': 70319, 'author': 'Weidenrinde', 'author_id': 11344, 'author_profile': 'https://Stackoverflow.com/users/11344', 'pm_score': 5, 'selected': False, 'text': '<p>For Linux:\n <a href="http://github.com/gperftools/gperftools" rel="noreferrer">Google Perftools</a></p>\n\n<ul>\n<li>Faster than valgrind (yet, not so fine grained)</li>\n<li>Does not need code instrumentation</li>\n<li>Nice graphical output (--> kcachegrind)</li>\n<li>Does memory-profiling, cpu-profiling, leak-checking</li>\n</ul>\n'}, {'answer_id': 70338, 'author': 'Dark Shikari', 'author_id': 11206, 'author_profile': 'https://Stackoverflow.com/users/11206', 'pm_score': 3, 'selected': False, 'text': '<p>oprofile, without a doubt; its simple, reliable, does the job, and can give all sorts of nice breakdowns of data.</p>\n'}, {'answer_id': 76797, 'author': 'eli', 'author_id': 12893, 'author_profile': 'https://Stackoverflow.com/users/12893', 'pm_score': 2, 'selected': False, 'text': "<p>I have tried Quantify an AQTime, and Quantify won because of its invaluable 'focus on sub tree' and 'delete sub tree' features.</p>\n"}, {'answer_id': 111053, 'author': 'Fabien Hure', 'author_id': 19912, 'author_profile': 'https://Stackoverflow.com/users/19912', 'pm_score': 2, 'selected': False, 'text': '<p>The only sensitive answer is <a href="http://softwarecommunity.intel.com/articles/eng/1437.htm" rel="nofollow noreferrer">PTU</a> from Intel. Of course its best to use it on an Intel processor and to get even more valuable results at least on a C2D machine as the architecture itself is easier to give back meaningful profiles.</p>\n'}, {'answer_id': 127275, 'author': 'user15071', 'author_id': 15071, 'author_profile': 'https://Stackoverflow.com/users/15071', 'pm_score': 2, 'selected': False, 'text': '<p>For Windows, check out <a href="http://blogs.msdn.com/pigscanfly/archive/2008/02/09/xperf-a-new-tool-in-the-windows-sdk.aspx" rel="nofollow noreferrer">Xperf</a>. It uses sampled profile, has some useful UI, &amp; does not require instrumentation. Quite useful for tracking down performance problems. You can answer questions like:</p>\n\n<ul>\n<li>Who is using the most CPU? Drill down to function name using call stacks.</li>\n<li>Who is allocating the most memory?</li>\n<li>Who is doing the most registry queries?</li>\n<li>Disk writes? etc.</li>\n</ul>\n\n<p>You will be quite surprised when you find the bottlenecks, as they are probably not where you expected!</p>\n'}, {'answer_id': 129961, 'author': 'rlerallut', 'author_id': 20055, 'author_profile': 'https://Stackoverflow.com/users/20055', 'pm_score': 2, 'selected': False, 'text': '<p>Since you don\'t mention the platform you\'re working on, I\'ll say cachegrind under Linux. Definitely. It\'s part of the Valgrind toolset.</p>\n\n<p><a href="http://valgrind.org/info/tools.html" rel="nofollow noreferrer">http://valgrind.org/info/tools.html</a></p>\n\n<p>I\'ve never used its sub-feature Callgrind, since most of my code optimization is for <em>inside</em> functions.</p>\n\n<p>Note that there is a frontend KCachegrind available.</p>\n'}, {'answer_id': 153607, 'author': 'Shog9', 'author_id': 811, 'author_profile': 'https://Stackoverflow.com/users/811', 'pm_score': 2, 'selected': False, 'text': '<p>For Windows development, I\'ve been using Software Verification\'s <a href="http://www.softwareverify.com/cpp/profiler/index.html" rel="nofollow noreferrer">Performance Validator</a> - it\'s fast, reasonably accurate, and reasonably priced. Best yet, it can instrument a running process, and lets you turn data collection on and off at runtime, both manually and based on the callstack - great for profiling a small section of a larger program.</p>\n'}, {'answer_id': 153906, 'author': 'Don Neufeld', 'author_id': 13097, 'author_profile': 'https://Stackoverflow.com/users/13097', 'pm_score': 2, 'selected': False, 'text': "<p>I've used VTune under Windows and Linux for many years with very good results.  Later versions have gotten worse, when they outsourced that product to their Russian development crew quality and performance both went down (increased VTune crashes, often 15+ minutes to open an analysis file).</p>\n\n<p>Regarding instrumentation, you may find out that it's less useful than you think.  In the kind of applications I've worked on adding instrumentation often slows the product down so much that it doesn't work anymore (true story: start app, go home, come back next day, app still initializing).  Also, with non instrumented profiling you can react to live problems.  For example, with VTune remote date collector I can start up a sampling session against a live server with hundreds of simultaneous connections that is experiencing performance problems and catch issues that happen in production that I'd never be able to replicate in a test environment.</p>\n"}, {'answer_id': 155283, 'author': 'Qwertie', 'author_id': 22820, 'author_profile': 'https://Stackoverflow.com/users/22820', 'pm_score': 2, 'selected': False, 'text': '<p>For Windows, I\'ve tried AMD Codeanalyst, Intel VTune and the profiler in Visual Studio Team Edition. </p>\n\n<p>Codeanalyst is buggy (crashes frequently) and on my code, its results are often inaccurate.  Its UI is unintuitive. For example, to reach the call stack display in the profile results, you have to click the "Processes" tab, then click the EXE filename of your program, then click a toolbar button with the tiny letters "CSS" on it. But it is freeware, so you may as well try it, and it works (with fewer features) without an AMD processor.</p>\n\n<p>VTune ($700) has a <a href="http://blog.vlad1.com/2008/07/16/why-cant-vtune-be-more-like-shark/" rel="nofollow noreferrer">terrible user interface</a> IMO; in a large program, it\'s hard to find the particular call tree you want, and you can only look at one "node" in a program at a time (a function with its immediate callers and callees)--you cannot look at a complete call tree. There is a call graph view, but I couldn\'t find a way to make the relative execution times appear on the graph. In other words, the functions in the graph look the same regardless of how much time was spent in them--it\'s as though they totally missed the point of profiling.</p>\n\n<p>Visual Studio\'s profiler has the best GUI of the three, but for some reason it is unable to collect samples from the majority of my code (samples are only collected for a few functions in my entire C++ program). Also, I couldn\'t find a price or way to buy it directly; but it comes with my company\'s MSDN subscription. Visual Studio supports managed, native, and mixed code; I\'m not sure about the other two profilers in that regard.</p>\n\n<p>In conclusion, I don\'t know of a good profiler yet! I\'ll be sure to check out the other suggestions here.</p>\n'}, {'answer_id': 175204, 'author': 'Michael McCarty', 'author_id': 25007, 'author_profile': 'https://Stackoverflow.com/users/25007', 'pm_score': 2, 'selected': False, 'text': '<p>ElectricFence works nicely for malloc debugging</p>\n'}, {'answer_id': 264007, 'author': 'Mike Dunlavey', 'author_id': 23771, 'author_profile': 'https://Stackoverflow.com/users/23771', 'pm_score': 3, 'selected': False, 'text': '<p>IMHO, <a href="http://www.wikihow.com/Optimize-Your-Program%27s-Performance" rel="noreferrer">sampling using a debugger</a> 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.</p>\n'}, {'answer_id': 264035, 'author': 'EvilTeach', 'author_id': 7734, 'author_profile': 'https://Stackoverflow.com/users/7734', 'pm_score': 2, 'selected': False, 'text': '<p>I use <a href="http://www.compuware.com/products/devpartner/default.htm" rel="nofollow noreferrer">devpartner</a> for the pc platform.</p>\n'}, {'answer_id': 1458576, 'author': 'Dimitri C.', 'author_id': 74612, 'author_profile': 'https://Stackoverflow.com/users/74612', 'pm_score': 3, 'selected': False, 'text': '<p>The profiler in <strong>Visual Studio 2008</strong> is very good: fast, user friendly, clear and well integrated in the IDE.</p>\n'}, {'answer_id': 3012934, 'author': 'charfeddine.ahmed', 'author_id': 363247, 'author_profile': 'https://Stackoverflow.com/users/363247', 'pm_score': 1, 'selected': False, 'text': '<p>My favorite tool is Easy Profiler : <a href="http://code.google.com/p/easyprofiler/" rel="nofollow noreferrer">http://code.google.com/p/easyprofiler/</a></p>\n\n<p>It\'s a compile time profiler : the source code must be manually instrumented using a set of routines so to describe the target regions.\nHowever, once the application is run, and measures automatically written to an XML file, it is only a matter of opening the Observer application and doing few clicks on the analysis/compare tools, before you can see the result in a qualitative chart.</p>\n'}, {'answer_id': 4233209, 'author': 'Moberg', 'author_id': 393010, 'author_profile': 'https://Stackoverflow.com/users/393010', 'pm_score': 3, 'selected': False, 'text': '<p>I have never done profiling before. Yesterday I programmed a ProfilingTimer class with a static timetable (a map&lt;std::string, long long&gt;) for time storage.</p>\n\n<p>The constructor stores the starting tick, and the destructor calculates the elapsed time and adds it to the map:</p>\n\n<pre><code>ProfilingTimer::ProfilingTimer(std::string name)\n : mLocalName(name)\n{\n sNestedName += mLocalName;\n sNestedName += " &gt; ";\n\n if(sTimetable.find(sNestedName) == sTimetable.end())\n  sTimetable[sNestedName] = 0;\n\n mStartTick = Platform::GetTimerTicks();\n}\n\nProfilingTimer::~ProfilingTimer()\n{\n long long totalTicks = Platform::GetTimerTicks() - mStartTick;\n\n sTimetable[sNestedName] += totalTicks;\n\n sNestedName.erase(sNestedName.length() - mLocalName.length() - 3);\n}\n</code></pre>\n\n<p>In every function (or {block}) that I want to profile i need to add:</p>\n\n<pre><code>ProfilingTimer _ProfilingTimer("identifier");\n</code></pre>\n\n<p>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 %.</p>\n\n<p>(Is anyone else working with any similar "home-made profiling"? Or is it just stupid? But it\'s fun! Does anyone have improvement suggestions?</p>\n\n<p>Is there some sort of auto-adding a line to all functions?)</p>\n'}, {'answer_id': 4233231, 'author': 'Coder', 'author_id': 459930, 'author_profile': 'https://Stackoverflow.com/users/459930', 'pm_score': 1, 'selected': False, 'text': "<p>Visual studio 2010 profiler under Windows. VTune had a great call graph tool, but it got broken as of Windows Vista/7. I don't know if they fixed it.</p>\n"}, {'answer_id': 7619553, 'author': 'Brian Kennedy', 'author_id': 968565, 'author_profile': 'https://Stackoverflow.com/users/968565', 'pm_score': 0, 'selected': False, 'text': '<p>Let me give a plug for EQATEC... just what I was looking for... simple to learn and use and gives me the info I need to find the hotspots quickly.  I much prefer it to the one built in to Visual Studio (though I haven\'t tried the VS 2010 one yet, to be fair).</p>\n\n<p>The ability to take snapshots is HUGE.  I often get an extra analysis and optimization done while waiting for the real target analysis to run... love it.</p>\n\n<p>Oh, and its base version is free!<br>\n<a href="http://www.eqatec.com/Profiler/" rel="nofollow">http://www.eqatec.com/Profiler/</a></p>\n'}]
['https://Stackoverflow.com/questions/26663', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2638/']