andrew4582

Time<T>

Aug 19th, 2011
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.30 KB | None | 0 0
  1.     /// <summary>Times the execution of a function and outputs both the elapsed time and the function's result.</summary>
  2.     static void Time<T>(Func<T> work)
  3.     {
  4.         var sw = Stopwatch.StartNew();
  5.         var result = work();
  6.         Console.WriteLine(sw.Elapsed + ": " + result);
  7.     }
Advertisement
Add Comment
Please, Sign In to add comment