private BenchmarkRunList Run(Action action, int iterationCount, Predicate <BenchmarkRunList> stopPredicate = null) { var runList = new BenchmarkRunList(); var stopwatch = new Stopwatch(); for (int i = 0; i < iterationCount; i++) { stopwatch.Reset(); stopwatch.Start(); action(); stopwatch.Stop(); var run = new BenchmarkRun(stopwatch); runList.Add(run); if (PrintToConsole) { run.Print(); } if (stopPredicate != null && stopPredicate(runList)) { break; } } if (PrintToConsole) { runList.PrintStatistic(); } return(runList); }
private bool StopWarmUpPredicate(BenchmarkRunList runList) { if (runList.Count < WarmUpIterationCount) { return(false); } var lastRuns = new BenchmarkRunList(); for (int i = 0; i < WarmUpIterationCount; i++) { lastRuns.Add(runList[runList.Count - WarmUpIterationCount + i]); } return(lastRuns.Error < MaxWarpUpError); }