239

I'm looking for a profiler in order to find the bottleneck in my C++ code. I'd like to find a free, non-intrusive, and good profiling tool. I'm a game developer, and I use PIX for Xbox 360 and found it very good, but it's not free. I know the Intel VTune, but it's not free either.

Sam Mason
  • 15,216
  • 1
  • 41
  • 60
ugasoft
  • 3,778
  • 7
  • 27
  • 23

13 Answers13

141

CodeXL has now superseded the End Of Line'd AMD Code Analyst and both are free, but not as advanced as VTune.

There's also Sleepy, which is very simple, but does the job in many cases.

Note: All three of the tools above are unmaintained since several years.

Zitrax
  • 19,036
  • 20
  • 88
  • 110
yrp
  • 4,565
  • 2
  • 24
  • 10
  • 5
    Here is the link for CodeAnalyst: http://developer.amd.com/CPU/CODEANALYST/Pages/default.aspx – epotter Feb 19 '09 at 17:19
  • 1
    I tried working with it now, and didn't like it at all. I couldn't even understand how to get function's total time % (including the callees) which TrueTime could do fine 10 years ago. – Pavel Radzivilovsky Mar 13 '11 at 15:05
  • I wrote an adaptation of sleepy which doesn't depend in wxWidgets but runs in the command line. You run it for a period of time against a running process and then when you stop it, you get the stats of what the process was spending its time doing. It is non-intrustive in that you don't have to modify your code in any way to use it, but it does suspend your threads as it reads the call-stacks. You also need the pdb files available so that you can get meaningful output, but I guess that applies to any profiler. – CashCow Feb 13 '12 at 10:44
  • I would recommend trying xperf I found it superior to AMD code analyst. – MW_dev May 01 '13 at 01:21
  • 1
    CodeAnalyst won't be receiving any more updates except for critical bug fixes. They switched to CodeXL. [Here's the link](http://developer.amd.com/tools-and-sdks/opencl-zone/opencl-tools-sdks/codexl/) so you can update your answer. And thanks for letting me now about CodeAnalyst/XL, by the way. – Adri C.S. Jun 05 '14 at 16:14
  • Tried out CodeXL, which is successor of AMD Code Analyst. It can't attach to the existing process. And as for Sleepy, it crashes after 5 seconds of profiling. Both tools are rubbish... – user2846246 Jun 27 '14 at 10:40
  • Worth mentioning that CodeXL works best on AMD processors. On non-AMD it can **not** show method-level-accurate timings. – rustyx Oct 06 '15 at 10:44
  • AMD CodeXL just doesn't work. It crashes visual studio, most panels never gather any data and the output is confusing. It also doesn't load symbols from project automatically. – Tomáš Zato Oct 23 '15 at 08:15
67

Very Sleepy is a C/C++ CPU profiler for Windows systems (free).

Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313
lsalamon
  • 7,998
  • 6
  • 50
  • 63
36

Proffy is quite cool: http://pauldoo.com/proffy/

Disclaimer: I wrote this.

pauldoo
  • 18,087
  • 20
  • 94
  • 116
19

There is an instrumenting (function-accurate) profiler for MS VC 7.1 and higher called MicroProfiler. You can get it here (x64) or here (x86). It doesn't require any modifications or additions to your code and is able of displaying function statistics with callers and callees in real-time without the need of closing application/stopping the profiling process.

It integrates with VisualStudio, so you can easily enable/disable profiling for a project. It is also possible to install it on the clean machine, it only needs the symbol information be located along with the executable being profiled.

This tool is useful when statistical approximation from sampling profilers like Very Sleepy isn't sufficient.

Rough comparison shows, that it beats AQTime (when it is invoked in instrumenting, function-level run). The following program (full optimization, inlining disabled) runs three times faster with micro-profiler displaying results in real-time, than with AQTime simply collecting stats:

void f()
{
    srand(time(0));

    vector<double> v(300000);

    generate_n(v.begin(), v.size(), &random);
    sort(v.begin(), v.end());
    sort(v.rbegin(), v.rend());
    sort(v.begin(), v.end());
    sort(v.rbegin(), v.rend());
}
Arty
  • 723
  • 5
  • 10
  • 1
    It's easy to use and super-fast profiler. Only one issue I didn't solve is a problem that after I finished debugging, profiler window didn't close automatically and you have to kill it through task manager (without that you can't recompile your project). – Ludek Vodicka Oct 24 '12 at 07:39
  • 1
    I found that after I close my app by regular CLOSE button, profiler window can be closed regularly too. But when I exit app by SHIFT+F5 shortcut (Stop debugging VS command), profiler window close button is disabled. – Ludek Vodicka Oct 24 '12 at 07:42
  • Does not work with VS 2015. – rustyx Oct 26 '15 at 15:39
  • 1
    Fixed as of 1.1.590. See updates on Visual Studio Gallery page (https://visualstudiogallery.msdn.microsoft.com/133d5764-b32b-4ec9-8ee8-5546eca64584) – Arty Oct 26 '15 at 21:31
  • 1
    This is really really good! Should be ranked way higher! Super simple to install and run, and gives you most of what you need to know. My second choice is Windows Performance Analyzer: http://geekswithblogs.net/akraus1/archive/2015/04/21/163342.aspx – Steve Jan 14 '16 at 00:27
  • You can install it directly into Visual Studio (2017+) from the `Tools \ Extensions and Updates` menu. A `MicroProfiler` menu item then appears on the main menu. – Den-Jason Aug 25 '20 at 18:23
  • On VS there is also a `CPU Usage` tab on the `Diagnostic Tools` group – Den-Jason Aug 25 '20 at 18:43
10

Microsoft has the Windows Performance Toolkit.

It does require Windows Vista, Windows Server 2008, or Windows 7.

Community
  • 1
  • 1
epotter
  • 7,631
  • 7
  • 63
  • 88
  • 6
    How is it not free? It is a part of the Windows SDK. I was able to download it without any problems. (Admittedly, we have an MSDN subscription, so some people might have a different experience than I do.) – epotter Jul 26 '11 at 12:32
  • 1
    Free or not, the link no longer works properly. – Tomáš Zato Oct 07 '15 at 11:11
6

Another profiler is Shiny.

​​​​​

Zitrax
  • 19,036
  • 20
  • 88
  • 110
Buggieboy
  • 4,636
  • 4
  • 55
  • 79
5

I highly recommend Windows Performance Analyzer (WPA) part of the Windows Performance Toolkit. The command line Windows Performance Recorder (WPR) tool records Event Tracing for Windows (ETW) logs that can be analyzed later using the Windows Performance Analyzer tool. There are some great tutorials on learning how to use the tool.

wpr.exe -start CPU
...
wpr.exe -stop output.etl
wpa.exe output.etl
MW_dev
  • 2,146
  • 1
  • 26
  • 40
  • 1
    Well I know I'm missing working URL to the site. – Tomáš Zato Oct 23 '15 at 08:35
  • I've just tried it, but it never loads the .pdb for my application (after adding the build folder to the symbol path), so it's kinda useless if you actually want to profile C++ code. It's useful if you want to learn everything else the system was doing - it provides an amazing big picture. But for C++ profiling it just didn't do anything. – Kuba hasn't forgotten Monica Jul 06 '20 at 16:38
  • Thats because you need to update the version. There are known buggy versions, try the one from the windows store. – MW_dev Mar 15 '22 at 10:34
3

I use AQTime, it is one of the best profiling tools I've ever used. It isn't free but you can get a 30 day trial, so if you plan on a optimizing and profiling only one project and 30 days are enough for you then I would recommend using this application. (http://www.automatedqa.com/downloads/aqtime/index.asp)

Zitrax
  • 19,036
  • 20
  • 88
  • 110
dudico
  • 555
  • 2
  • 4
  • 11
1

I used Luke Stackwalker and it did the job for my Visual Studio project.

Other interesting projects are:

INS
  • 10,594
  • 7
  • 58
  • 89
1

Please try my profiler, called cRunWatch. It is just two files, so it is easy to integrate with your projects, and requires adding exactly one line to instrument a piece of code.

http://ravenspoint.wordpress.com/2010/06/16/timing/

Requires the Boost library.

ravenspoint
  • 19,093
  • 6
  • 57
  • 103
0

You can use EmbeddedProfiler, it's free for both Linux and Windwos.

The profiler is intrusive (by functionality) but it doens't require any code modifications. Just add a specific compiler flag (-finstrument-functios for gcc/MinGW or /GH for MSVC) and link the profiler's library. It can provide you a full call tree or just a funciton list. It has it's own analyzer GUI.

Mi-La
  • 685
  • 10
  • 18
0

I use VSPerfMon which is the StandAlone Visual Studio Profiler. I wrote a GUI tool to help me run it and look at the results.

http://code.google.com/p/vsptree/

0

I've used "TrueTime - part of Compuware's DevPartner suite for years. There's a [free version](you could try Compuware DevPartner Performance Analysis Community Edition.) available.

Harold Ekstrom
  • 1,538
  • 8
  • 7