static void Main(string[] args) { if (args.Length != 1) { Console.WriteLine("one and only arg has to be name of benchmark"); PrintAvailableBenchmarks(); Environment.Exit(1); } PrintSimdInfo(); string type = args[0]; IBenchmark benchmark = GetBenchmark(type); if (benchmark == null) { Console.WriteLine($"unknown benchmark '{type}'"); PrintAvailableBenchmarks(); Environment.Exit(2); } benchmark.Run(); if (Debugger.IsAttached) { Console.WriteLine("\nEnd."); Console.ReadKey(); } }
public async Task <bool> Run(IProgress <int> progress) { return(await Task <bool> .Run(() => { var config = Configuration; config.Result = benchmark.Run(config); //progress.Report(i++); return true; })); }
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; }
public async Task <bool> RunTests(double density, bool symmetric, IProgress <int> progress) { return(await Task <bool> .Run(() => { int count = Configurations.Count; int i = 1; foreach (var config in Configurations) { config.Density = density; config.Symmetric = symmetric; config.RowCount = (int)(Factor * config.RowCount); config.ColumnCount = (int)(Factor * config.ColumnCount); config.Result = test.Run(config); progress.Report(i++); } return true; })); }
private long RunSingleThread(IBenchmark test) { var stopwatch = Stopwatch.StartNew(); for (var i = 0; i < iterations; i++) { test.Run(); } stopwatch.Stop(); PrintResult(test, stopwatch); var disposable = test as IDisposable; if (disposable != null) { disposable.Dispose(); } return stopwatch.ElapsedMilliseconds; }
private long RunThreadBased(IBenchmark test) { var stopwatch = Stopwatch.StartNew(); var threads = new Thread[Environment.ProcessorCount]; var interval = iterations/threads.Length; for (var i = 0; i < threads.Length; i++) { var thread = new Thread(() => { for (var j = 0; j < interval; j++) { test.Run(); } }); threads[i] = thread; thread.Start(); } for (var i = 0; i < threads.Length; i++) { threads[i].Join(); } stopwatch.Stop(); PrintResult(test, stopwatch); var disposable = test as IDisposable; if (disposable != null) { disposable.Dispose(); } return stopwatch.ElapsedMilliseconds; }