public static string BenchMark(VoidMethod method, string description = "Method Execution", BenchmarkUnit unit = 0) => BenchMark(method, out long i, description, unit);
public static string BenchMark(VoidMethod method, out long executionTime, string description = "Method Execution", BenchmarkUnit unit = 0) { executionTime = 0; if (method == null) { return("No method present"); } stopWatch.Reset(); stopWatch.Start(); method(); stopWatch.Stop(); switch (unit) { case BenchmarkUnit.MilliSecond: default: executionTime = stopWatch.ElapsedMilliseconds; break; case BenchmarkUnit.MicroSecond: executionTime = stopWatch.ElapsedMilliseconds * 1000; break; case BenchmarkUnit.Tick: executionTime = stopWatch.ElapsedTicks; break; case BenchmarkUnit.Second: executionTime = stopWatch.ElapsedMilliseconds / 1000; break; } return(description + " takes: " + executionTime + " " + unit.ToString() + "s"); }