public static TimeSpan Time (string opName, Action action) { var mark = new Benchmark (opName).Start (); action (); mark.Stop (); logger.Info (mark.ToString ()); return mark.Elapsed; }
public static TimeSpan Time (string opName, Action action, int loopCount, bool warmup) { if (warmup) action (); var mark = new Benchmark (opName).Start (); for (var i = 0; i < loopCount; i++) action (); mark.Stop (); logger.Info (String.Format ("Timing for {0} run {1} times:\t {1}", opName, loopCount, mark.Elapsed)); return mark.Elapsed; }