Skip to content

Instantly share code, notes, and snippets.

@greglecki
Last active April 22, 2016 09:29
Show Gist options
  • Select an option

  • Save greglecki/689104e2f6f2f0f67586f1c2cc89728a to your computer and use it in GitHub Desktop.

Select an option

Save greglecki/689104e2f6f2f0f67586f1c2cc89728a to your computer and use it in GitHub Desktop.
Check execution time.
using System.Diagnostics;
private readonly Stopwatch stopwatch;
// Initialize should be done in class constructor
stopwatch = new Stopwatch();
// Usage
stopwatch.Start();
// Metod/algoritm to execute
stopwatch.Stop();
// Read elapsed time
Console.Write("The method took {0} seconds to complete", stopwatch.ElapsedMilliseconds / 1000);
// Start method acts to resume functionality when a stopwatch is stopped to start fresh call Reset method
stopwatch.Reset();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment