12

I'm looking for a way to find bottleneck methods in a solution (lots of projects).

Lets say i have a HUGE program (1000s of methods) and i want to improve performance by finding methods that are called a lot (actually used at runtime), and optimize them.
I need this for a complex problem that's written in C++, C#, CLI/C++. (I can compile it all in debug and have the .pdb files)
So, I'm looking for some kind of analyzer that will tell me how much cpu time each method is using.

What tool/addon/feature can I use in Visual Studio to get that information ?
I want to be able to run the program for a few minutes, and then analyze the method's cpu usage. Or even better - amount of cpu / number of calls.
Would be even better if I could sort by namespace or dll/package/project.

Yochai Timmer
  • 48,127
  • 24
  • 147
  • 185

4 Answers4

5

The more expensive Visual Studio versions should provide a Profiler builtin: see this thread.

However there are more methods to profile, this topic has been covered a lot of times on stackoverflow, here for example.

Community
  • 1
  • 1
Christian Goltz
  • 746
  • 3
  • 7
2

Following one of Christian Goltz links, I've found a program that might do what I want, it profiles both managed and unmanaged code:

AQTime Pro

Yochai Timmer
  • 48,127
  • 24
  • 147
  • 185
1

I'm had some good experiences with the DotTrace product by JetBrains. Not sure if it has the IDE integration or all the features that you're looking for, but it definitely gets the job done.

David
  • 208,112
  • 36
  • 198
  • 279
1

This method is low-tech, but works perfectly well.

I also work in a huge application, and when we have performance problems it finds them quickly.

Community
  • 1
  • 1
Mike Dunlavey
  • 40,059
  • 14
  • 91
  • 135
  • Well, I was doing that, but it doesn't work well with multiple threads (above like 5 you'll just get a random method in each). – Yochai Timmer Jul 16 '11 at 19:23
  • @Yochai: What I do is look at each one and understand what it's doing. Most of the time it's innocently waiting for work. Other times, it's actually doing something. Now, once is not enough. You gotta pause it enough times to see a thread doing something *more than once* that it doesn't strictly need to do. That's how you find the problems. – Mike Dunlavey Jul 16 '11 at 21:37
  • @Yochai: And on each stack, don't just look at the business end. Look at all of it, so you can get the full reason why it's doing what it's doing. That's how you can tell if it's strictly necessary. Often if *looks* like it is, but if you dig into it, you can see that it really can be avoided. (And of course, you pause it while it's doing whatever seems to be slow, not just when it's lying around with nothing to do.) – Mike Dunlavey Jul 16 '11 at 22:16
  • Yea I know, VS2010 has that nice window with all the stacks of all the threads. But with few 100 thousands lines of code, I still need proper profiling. – Yochai Timmer Jul 17 '11 at 04:19