How long does my code take to run?

benchmarking, c#, performance

Solution

Check out the `Stopwatch` class:

Stopwatch sw = new Stopwatch();
sw.Start();

// your code here

sw.Stop();
TimeSpan elapsedTime = sw.Elapsed;

Problem

How can I find out how much time my C# code takes to run?

Original source