Question

C# code

  1. Is it possible find the execution time of a set of code in visual studio?

  2. if visual studio does provide any tools for this what are the alternatives?

  3. are there any free reliable tools to download?

SQL server management studio

  1. Is it possible find the execution time of a set of code in SQL server Management studio?

  2. if SQL server Management studio does provide any tools for this what are the alternatives?

  3. are there any free reliable tools to download?

thanks

Was it helpful?

Solution

For SSMS Query execution time in miliseconds in SQL Server Management Studio

If you need to get query execution time in milliseconds in SQL Server Management Studio, there is a simple way to achieve this.

set statistics time on

-- your query 

set statistics time off

This will result in following lin in Messages window:

SQL Server Execution Times: CPU time = 16 ms, elapsed time = 16 ms.

OTHER TIPS

For C#:

Take a look at Profiling Manager in Visual Studio. It works wonders and solves many of life's programming problems trying to hunt down performance issues. It's under the Test menu in VS2010.

It can use several different techniques that you can choose from to best suit your performance debugging needs.

For SQL:

I typically just use performance timers, or DateTimes. Used in a stopwatch-like fashion.

If you just want to do some quick and dirty timing checks in .NET you can always create a stopwatch then start and stop it around the code in question. Quick, Free, and Ugly.

For C# if you don't want to use the profiler, and just want to know how long it took for a certain piece of code to execute you can use the stopwatch.

var sw = StopWatch.StartNew();
//some code...
sw.Stop();
Console.Writeline(sw.Elapsed);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top