Profiling a method in C# to know how long does it take to run
I need to get a timing report to know how long does it take to run a C# method in a class.
I think about using profiler
to do that.
The input is the name of a method in 开发者_如何学编程a class, the output is
- What method/class calls this method.
- The amount of time to run the method.
What tools/commercial products are available for that for Visual Studio 2010 and Mono?
You could use:
- CLR Profiler (free)
- Red Gate ANTS Performance Profiler ($400)
Both will provide you with call graphs and method timings. The Red Gate tool is nice and has a 14 day trial. It also provides line level timings, which I'm not sure if the free CLR Profiler tool will do for you.
Another opensource profiler is slimtune http://code.google.com/p/slimtune/
Alternatively you can create your own profiler using COM and the ICorProfilerCallback interfaces, but I would do this if you wanted a very customized profiler gathering.
To add to Michaels answer, there's also:
DotTrace ($400)
I personally perfer it over the Red Gate profiler.
精彩评论