Created
September 26, 2016 22:27
-
-
Save nbxx/13bd868ba70126b974b1239f73d98ad1 to your computer and use it in GitHub Desktop.
This file contains 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
static void Main(string[] args) | |
{ | |
RunStopwatch(() => | |
{ | |
foreach (var item in collection) | |
{ | |
DoSomething(item); | |
} | |
}); | |
} | |
public static void RunStopwatch(Action action) | |
{ | |
// Run action, record timespan | |
Stopwatch stopwatch = new Stopwatch(); | |
stopwatch.Start(); | |
action(); | |
stopwatch.Stop(); | |
Console.WriteLine(stopwatch.ElapsedMilliseconds); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment