You might need to know how much time a method in your application takes to execute.

This information would help you analyze the slow running methods in the application.There are various ways to achieve this — you can use profilers or write custom code to get this information.
Some of the popular performance profilers that you can use to profile your .Net applications are: RedGate ANTS Performance Profiler, JetBrains dotTrace, and Telerik Just Trace. You can also measure the execution time programmatically with a popular AOP library called PostSharp.Measuring the execution time programmatically
If you would like to measure the execution time of a method, i.e., the time a method takes to execute programmatically, you can use the Stopwatch class in the System.Diagnostics namespace, which can measure the elapsed time for one interval or to measure the total elapsed time for multiple intervals.

The following code snippet illustrates how you can leverage the Stopwatch class to measure execution time:To read this article in full or to leave a comment, please click here

Leave a Reply