public
Created

Stopwatch wrapper

  • Download Gist
with_timer.cs
C#
1 2 3 4 5 6 7 8 9 10 11 12 13
private T with_timer<T>(Func<T> action)
{
Stopwatch sw = Stopwatch.StartNew();
var result = action();
sw.Stop();
 
 
TimeSpan time = sw.Elapsed;
 
System.Console.WriteLine("Time: {0:00}:{1:00}:{2:00}.{3:000}", time.Hours, time.Minutes, time.Seconds, time.Milliseconds);
 
return result;
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.