24

Does windows have any decent sampling (eg. non-instrumenting) profilers available? Preferably something akin to Shark on MacOS, although i am willing to accept that i am going to have to pay for such a profiler on windows.

I've tried the profiler in VS Team Suite and was not overly impressed, and was wondering if there were any other good ones.

[Edit: Erk, i forgot to say this is for C/C++, rather than .NET -- sorry for any confusion]

Nickolay
  • 31,095
  • 13
  • 107
  • 185
olliej
  • 35,755
  • 9
  • 58
  • 55
  • I'd also love suggestions for profilers that are not so closely tied to VS, meaning those that can run stand-alone, and preferably make use of more debugging information formats than pdb. – aib Oct 04 '08 at 10:30

9 Answers9

16

For Windows, check out the free Xperf that ships with the Windows SDK. It uses sampled profile, has some useful UI, & does not require instrumentation. Quite useful for tracking down performance problems. You can answer questions like:

Who is using the most CPU? Drill down to function name using call stacks.

Who is allocating the most memory?

Outstanding memory allocations (leaks)

Who is doing the most registry queries?

Disk writes? etc.

user15071
  • 3,391
  • 8
  • 31
  • 31
  • 1
    XPerf seems great, but it cannot run on XP, it needs Vista or Server 2007 or newer. A pitty - the functionality sounds really great, callstack captures based on sampling profiling would be handy. – Suma Oct 04 '08 at 13:39
  • XPerf depends heavily on the revamped ETW in Vista, one of the little known improvements in Vista/Server08. – user15071 Oct 04 '08 at 16:02
  • argh.. yeah.. xp incompatible. so it starts... :( – Joao Vilaca Jan 12 '09 at 01:45
  • 1
    Xperf uses ETW infrastructure added with Windows Vista. Because of this it cannot profile an application; but profiles the entire system. And it requires administrative, command-line, access to start and stop logging. i.e. not very friendly – Ian Boyd Jun 16 '10 at 19:18
12

I know I'm adding my answer months after this question was asked, but I thought I'd point out a decent, open-source profiler: Very Sleepy.

It doesn't have the feature count that some of the other profilers mentioned before do, but it's a pretty respectable sampling profiler that will work very well in most situations.

Naaff
  • 9,213
  • 3
  • 38
  • 43
  • This looks like it can be a pretty good profiler. But it needs the ability to sample all threads in a process. And the process picker needs to include PID (since there are many Chrome.exe or iexplore.exe processes, but only one is the parent) – Ian Boyd Jun 16 '10 at 19:27
  • 1
    It's success rate in loading the .exe I wanted to profile hovered around 50%. Not fun. – quant_dev Sep 20 '11 at 13:20
  • I've managed to run it and profile an executable to find the hot spots. All debug symbols were loaded correctly, so I knew exactly where to look. – Michal Kottman May 22 '12 at 11:23
  • I'm struggling to get verySleepy to find my programs source, despite being built with all debug symbols... – Troyseph May 18 '21 at 16:23
11

Intel VTune is good and is non-instrumenting. We evaluated a whole bunch of profilers for Windows, and this was the best for working with driver code (though it does unmanaged user level code as well). A particular strength is that it reads all the Intel processor performance counters, so you can get a good understanding of why your code is running slowly, and it was useful for putting prefetch instructions into our code and sorting out data layout to work well with the cache lines, and the way cache lines get invalidated in multi core systems.

It is commercial, and I have to say it isn't the easiest UI in the world.

Dickon Reed
  • 3,575
  • 4
  • 23
  • 25
6

AMD's CodeAnalyst is FREE here

JWWalker
  • 22,385
  • 6
  • 55
  • 76
Die in Sente
  • 9,546
  • 3
  • 35
  • 41
4

We use both VTune and AQTime, and I can vouch for both. Which works best for you depends on your needs. Both have free trial versions - I suggest you give them a go.

Greg Whitfield
  • 5,649
  • 2
  • 30
  • 32
  • I am trying to compare VTune and AQTime. Can you please provide more deatils of their features? – amit kumar May 14 '09 at 06:00
  • Testing AQTime now and wow, AMD CodeAnalyst with it's primitive window did not even manage to show any results at all, but this... line by line performance, line by line dissassembly, call trees, you name it. Im pleased so far, and all easy to use. –  Dec 01 '10 at 20:22
3

The Windows Driver Kit includes a non-instrumenting user/kernel sampling profiler called "kernrate". It seems useful for profiling multi-process applications, applications that spend most of their time in the kernel, and device drivers (of course). It's also available in the KrView (Kernrate Viewer) and Windows Server 2003 Resource Kit Tools packages.

Kernrate works on Windows 2000 and later (unlike Xperf, which requires Vista / Server 2008). It's command-line based and the documentation has a somewhat intimidating list of options. I'm not sure if it can record call stacks or just the program counter. If you use a symbol server, make sure to put an up-to-date dbghelp.dll and symsrv.dll in the same directory as kernrate.exe to prevent it from using the ancient version of dbghelp.dll that is installed in %SystemRoot%\system32.

bk1e
  • 23,871
  • 6
  • 54
  • 65
2

I have tried Intel's vtune with a rather large project about two years ago. It was an instrumenting profiler then and it took so long to instrument the DLL that I was attempting to profile that I eventually lost patience after an hour.

The one tool that I have had quite good success and which i would highly recommend is that of AQTime. It not only provides excellent performance profiling resources but it also doe really good memory profiling which has been of significant help to me in tracking down memory leaks.

Jon Trauntvein
  • 4,453
  • 6
  • 39
  • 69
  • Intel VTune has two modes: instrumenting (can produce callstacks and callgraphs) and sampling (hotspots only, no callstacks). – Suma Oct 04 '08 at 13:40
1

Luke Stackwalker seems promising -- it's not as polished as I'd like, but it is open source and it does do something that seems very close to what @Mike Dunlavey keeps saying we ought to do. (Of course, it then tries to smoosh it all down into the typically-unhelpful call graphs that Mike is so weary of, but it shouldn't be too hard to fix that with the source as our ally.)

It even seems to count time spent waiting in the kernel, as far as I can tell...

SamB
  • 9,039
  • 5
  • 49
  • 56
  • I downloaded the source of Luke Stackwalker, hoping it would be easy to make it do the "right thing", but I was disappointed, because it collects statistics as it samples, and then throws away the samples. The statistics are function-oriented, not line-oriented, plus some sort of min-max-line within functions. If only they kept the samples, it would be easy to give, at the line level, percent of samples containing the line, and also drive a butterfly navigator, as Zoom & LTProf do. Then for serious coders, they could just let you look at individual samples. – Mike Dunlavey Sep 20 '10 at 00:02
  • Chances are the reason they threw away the samples is they thought they would take too much storage. You know my answer to that. Only a small number of samples is needed to find the problems, especially if you can manually control sampling. A large number of samples gives you greater measurement precision, which you don't need. – Mike Dunlavey Sep 20 '10 at 14:20
  • @Mike: Hmm, that does sound worse than I might have been thinking (I, obviously, can't remember what I was *actually* thinking at the time ;-). Still... it seemed to be an awful lot closer to the desired tool than, say, Hello World is. – SamB Oct 20 '10 at 04:32
  • I hoped so too. If I didn't have distractions like a real job and family, I would whip up a profiler, maybe starting from Luke Stackwalker source. I did actually build one in '93 for DOS. It did make a nice show, but for real work I fell back to the manual method. BTW, LTProf is pretty close, for Windows. – Mike Dunlavey Oct 20 '10 at 12:17
-3

I'm not sure what a non-instrumenting profiler is, but I can say for .NET I love RedGate's ANTS Profiler. Version 3 beats the MS version for ease of use and Version 4, which allows arbitrary time slices, makes MS look like a joke.

Jonathan Allen
  • 68,373
  • 70
  • 259
  • 447
  • 2
    Sampling profilers work by observing your program's state periodically, and are thus non-invasive, and work on executables without the source code. (Though you'd probably need debugging information to resolve the function calls, etc.) -- correct me if I'm wrong. – aib Oct 04 '08 at 10:28
  • @aib: it certainly helps to have function names/stack layout info, yes, but of course .NET has that anyway (though it is possible to mutilate the names such that they are essentially numbers...). Line numbers don't hurt either, of course, and those you do need debug info for regardless. – SamB Apr 20 '10 at 17:00