Created
December 12, 2018 22:10
-
-
Save bpringe/ce96b5a3e7b49058022753370468f61f to your computer and use it in GitHub Desktop.
Function to print time of operation and return result
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
public static T Time<T>(string op, Func<T> f) | |
{ | |
var sw = Stopwatch.StartNew(); | |
T result = f(); | |
sw.Stop(); | |
Console.WriteLine($"{op} took {sw.ElapsedMilliseconds} ms"); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment