public void CanMeasureSingleMethod() { var result = BenchmarkEngine.ExecuteSingle(typeof(SingleBenchmark)); Assert.IsTrue(result >= TimeSpan.FromMilliseconds(1), "Average execution time cannot be smaller than minimum expected value."); Assert.IsTrue(result <= TimeSpan.FromMilliseconds(10), "Average execution time cannot be too much higher than maximum expected value."); }
public void CanDiscoverTypesInAssembly() { var engine = new BenchmarkEngine(new BenchmarkOptions() { Repetitions = 1 }, new Assembly[] { GetType().Assembly }); var results = engine.Execute(); Assert.AreEqual(3, results.Count(), "This test library contains three valid benchmark classes."); }
public void CanQuicklyCreateReport() { var tempPath = BenchmarkEngine.ExecuteAndRenderWithDefaults(null, new BenchmarkOptions() { Repetitions = 1 }); Assert.IsTrue(File.Exists(tempPath)); File.Delete(tempPath); }
static void Main() { Console.WriteLine("Performing benchmarks..."); //Process.Start(BenchmarkEngine.ExecuteAndRenderWithDefaults(null, new BenchmarkOptions { Repetitions = 10 })); var engine = new BenchmarkEngine(new BenchmarkOptions { Repetitions = 10 }, new Assembly[] { typeof(Program).Assembly }); var renderer = new ExcelOutputRenderer(); string outputPath = Path.Combine(Path.GetTempPath(), DateTime.Now.Ticks.ToString() + ".xlsx"); renderer.RenderTo(outputPath, engine.Execute()); Process.Start(outputPath); }