views:

652

answers:

6

complaining {

I always end up incredibly frustrated when I go to profile my code using Visual Studio 2008's profiler (from the Analyze menu option). It is one of the poorest designed features of VS, in my opinion, and I cringe every time I need use it.

}

I have a few questions concerning it's use, I'm hoping you guys can give me some pointers :-)

  1. Do you need to have your projects built in Debug or Release to profile them? One dialog (that I have no idea how to get back to) mentioned I should profile under Release. Okay - I do that - when I go to run the code, it tells me I'm missing PDB files. Awesome. So I go back to Debug mode, and I try to run it, and it tells me that half of my projects need to be recompiled with the /PROFILE switch on.
  2. Is it possible to profile C++/CLI projects? With the /PROFILE switch on, half of the time I get absolutely no output from my C++/CLI projects.
  3. Why, when attempting to profile C# projects, do they show up in the Report under Modules view Name list as 0x0000001, 0x0000002, 0x0000003, etc? Really, VS? Really? You can't take a guess at the names of my modules?
  4. For that matter, why are function names reported as 0x0A000011, 0x06000009, 0xA0000068, etc?
  5. Why, oh why, does VS rebuild EVERYTHING in the dependency tree of the executable being profiled? It might not be a problem if you have 5-6 projects in your solution, but when you have 70, it's almost quicker to not even bother with the profiler.
  6. Can you recommend any good guides on using the VS2008 profiler?
+1  A: 

I have the same feeling about that thing. I ended up writing my own (all I wanted was decent method call timing info).

leppie
+3  A: 

If you're finding it difficult to use, there's a really great .NET profiler called nprof, and if you're debugging non-CLR projects, AMD has a really spectacular statistical profiler called Code Analyst.

Both are free(!), and exceedingly easy to use. A much nicer alternative, and I expect from your post above you're about ready to ditch the VS builtin profiler anyway :)

Mike
You, sir, may just be my hero, I'm going to check those out right now!
unforgiven3
unless im missing something nprof has not had any activity for the last 3 years
Sam Saffron
+2  A: 

To complement Mike's answer with a related question: Any decent C# profilers out there?.

Pontus Gagge
+1  A: 

1.Do you need to have your projects built in Debug or Release to profile them?

Normally you use Release mode.

6.Can you recommend any good guides on using the VS2008 profiler?

Step 1, download ANTS Profiler.

Step 2, follow the easy to use on screen instructions.

Step 3, look at the easy to read reports.

Seriously, the Microsoft profiler is garbage compared to ANTS.

Jonathan Allen
The ANTS Profiler is very easy to use but not as powerful as the Visual Studio 2008's profiler. Most of the time the ANTS Profiler will do what you want with only ten percent of the afford of using the Visual Studio profiler.
Ian Ringrose
+1  A: 

Just a general comment. There are a couple reasons people profile.

  1. To get a variety of timing info.
  2. To find out what they could fix to make their program faster.

These are very different goals.

If your reason is the second one, using a profiler is not the only way. See here

Mike Dunlavey
Nope. Just take that 100ms code and wrap it in a loop to execute it 1000 times. That's about 100sec. Pause it a few times. See what it's wasting time at. Fix it, and remove the outer loop. Voila'
Mike Dunlavey
It's quite scientific. Any instruction that's on the call stack X% of the time (like 20%) whether or not it's a call instruction, is an opportunity to save X% of time. Work on one thread at a time. Do what you want, but if you try it you'll see.
Mike Dunlavey
... one of the things I run into is that people have a concept of "the culprit" as if they have a prior notion of what it is. The method finds "a culprit" (not expected) but having real cost. Then you can repeat it. Any culprit, even "the culprit" will eventually be found this way.
Mike Dunlavey
A: 

instructions on profiling for starters here! http://sivakrishnakuchi.blogspot.com/2010/04/how-to-use-visual-studio-profiler.html

Siva