private void PrintResult(IBenchmark test, Stopwatch stopwatch) { if (results == Results.Total_time) { Console.WriteLine(" Hey {0,-20} - you did it in {1,10}", test.GetType().Name, stopwatch.Elapsed); } else { Console.WriteLine(" Hey {0,-20} - you did {1,10} operations per second", test.GetType().Name, (iterations*oneSecondTicks)/stopwatch.Elapsed.Ticks); } }
private static bool ShouldRun(Regex filter, IBenchmark benchmark) { if (filter == null) return true; var name = benchmark.GetType().Name; var shouldRun = filter.IsMatch(name); return shouldRun; }
public void Run() { _benchmark.Setup(); var time = new TimeSpan(10000000); var runnables = new List <Runnable>() { new Runnable(_benchmark.LtQuery), new Runnable(_benchmark.Dapper), new Runnable(_benchmark.EFCore), }; var count = 0; var start = DateTime.Now; while (true) { if (DateTime.Now - start > time) { break; } foreach (var runnable in runnables) { runnable.Run(); } if (count == 0) { var accums = runnables.Select(_ => _.Accum); if (accums.Distinct().Count() != 1) { throw new Exception("accums are not match"); } } count++; } _benchmark.Cleanup(); using (var writer = new StreamWriter($"{_benchmark.GetType()}.txt")) { writer.WriteLine("Item, Time[ms]"); //foreach (var runnable in runnables) // writer.WriteLine($"{runnable}, {runnable.ElapsedMilliseconds / count}"); writer.WriteLine($"LtQuery, {runnables[0].ElapsedMilliseconds / count}"); writer.WriteLine($"Dapper, {runnables[1].ElapsedMilliseconds / count}"); writer.WriteLine($"EFCore, {runnables[2].ElapsedMilliseconds / count}"); } }
private long RunContinuously(IBenchmark test) { Console.WriteLine(" Testing {0,-20}", test.GetType().Name); for (var i = 0; i < iterations; i++) { test.Run(); } PrintResult(test); var disposable = test as IDisposable; if (disposable != null) { disposable.Dispose(); } return 0; }
private long RunWithStop(IBenchmark test) { Console.WriteLine(" Testing {0,-20}", test.GetType().Name); var count = 0; for (var i = 0; i < iterations; i++) { count++; test.Run(); if (count == memorySnapshotStep) { CollectSnapshot(i); count = 0; } } PrintResult(test); var disposable = test as IDisposable; if (disposable != null) { disposable.Dispose(); } return 0; }
private void PrintResult(IBenchmark test) { Console.WriteLine(" Hey {0,-20} - you're done. Collect snapshot and proceed with enter", test.GetType().Name); Console.ReadLine(); }
public BenchmarkInfo(IBenchmark benchmark) { this.Category = benchmark.Category; this.Name = benchmark.Name; this.FullName = benchmark.GetType().FullName; }
public BenchmarkInfo(IBenchmark benchmark) { this.Name = benchmark.Name; this.FullName = benchmark.GetType().FullName; }