views:

269

answers:

4

As a C# programmer, i'm in a transition from small projects to medium projects. I didn't need a profiler for my little projects before. But now I need a tool that help me improving the performance of my code. I used gprof many years ago, in C.

Can someone give me a starting point, or recommend me a tool like gprof for VS2008? That is: A tool that counts how many times every function has been called, and how many time It's spended in every function. No matter if a had to pay for it (under certains limits).

Any other advice about how to locate portions of code that should be optimized will be great.

Thanks.

+2  A: 

Visual Studio has this functionality built in depending on the version you are using. Within Professional (I believe), you have the Profiling section which gives you timing within functions inclusive and exclusive of further calls, # of calls etc...

It is normally located under the 'Analyze' menu option if it's there.

EDIT

Come VS2010 this has also been greatly improved. Featuring some very cool looking multi-threaded performance analysis, showing you what sort of operations the thread spends its time doing/blocking on. It also displays line by line timings I believe within your code (certainly the last screenshot I saw did).

Ian
Actually, I think it's only in Team System Developer or Team Suite edition there is support for Performance Profiling. In VS 2010 I would expect that to translate to the Premium edition.
CodingInsomnia
I can find the performance tools under the tools menu. I think it isn't available in VS profesional.
Jonathan
Looking around I think andliju is right, it may well be Team Editon only.
Ian
Last time I looked, the VS profiler could take time-based stack samples, but not during I/O or other system calls. Is that still the case? If it can't sample on wall-clock time, including during I/O, it would miss all performance problems consisting of excess I/O.
Mike Dunlavey
Mike, I can't remember all the details but saw a PCD2009? video whereby there profiling clearly showed one thread was blocking all the others with some IO based operations.
Ian
@Ian: OK, then does it show you which IO request in each thread is blocked, and what is the chain of function calls in the thread explaining why that thread is waiting for that IO? I think that's what you need to know if you're going to do something about it. Stack samples while they are blocked would tell you that, but you won't get them if it doesn't sample a thread while it's blocked.
Mike Dunlavey
+2  A: 

Check out the Ants profiler

Ramesh Vel
+1  A: 

I've used DotTrace and AQTime both are easy to use and understand.

Dror Helper