Last active
April 22, 2016 09:29
-
-
Save greglecki/689104e2f6f2f0f67586f1c2cc89728a to your computer and use it in GitHub Desktop.
Check execution time.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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