Search code examples
.netsqltestingperformancemeasure

Best way to measure speed of functions, classes and processes


What is the best way to measure speed of functions and classes? For every function there are various solutions and I'd like to know how to measure running speed and optimize my shared classes with the best solution possible.

Also how do you measure SQL speed, for example differences between stored procedures, selects, views and etc.?


Solution

  • You have two options.

    Use System.Diagnostics.Stopwatch for specific methods.

    This is a high resolution timer in .NET which you can use for specific parts of your code.

    Use a profiler if you need to measure performance for your entire application.

    You can use the build in profiler of the Ultra edition of Visual Studio, or a tool like EQATEC.