How to evaluate methods timing in Visual Studio

2019-08-06 07:20发布

问题:

I developed a very complex webservice that performs a lot of operation, in particular operation on SqlServer.

Is it possible, while I'm attached to the deployed webservice, to monitor timing of every methods to understand where are the most time consuming ones?

Otherwise I've to put in my code a lot of stopwatches, and write somewhere the result.

Any idea to achieve my goal within visual studio?

Thanks!

回答1:

Logging with stopwatches is good idea especially for undefined-time operations like calling a web service. This will enable you to investigate issues in release environment.

But if you have to investigate some performance issue locally, nothing is better than a specialized performance profiler. Visual studio 2010 (and I believe 2013) has a very good performance analyzer (included in Developer, Team and Ultimate editions as I remember). Here is beginner guide on it.

There are plenty other profilers, but for the needs you've described integrated Visual studio profiler will be more than fine.