internal static Options?ParseOptions(Arguments arguments) { var options = new Options { Benchmark = arguments.Benchmark, Runs = arguments.Runs }; if (arguments.MultiThreaded && (arguments.SingleThreaded || arguments.SingleMultiThreaded) || arguments.SingleThreaded && arguments.SingleMultiThreaded) { Console.WriteLine("Only one mode can be specified"); return(null); } if (arguments.MultiThreaded) { options.BenchmarkingMode = Options.Mode.MULTI_THREADED; } else if (arguments.SingleThreaded) { options.BenchmarkingMode = Options.Mode.SINGLE_THREADED; } else { options.BenchmarkingMode = Options.Mode.BOTH; } if (arguments.ListBenchmarks) { Console.WriteLine(string.Join(Environment.NewLine, new Runner(options, new NullLogger <Runner>()).GetListOfBenchmarksAndCategories())); return(null); } if (arguments.ListResults) { var saver = new ResultSaver(); foreach (var saveName in saver.GetListOfSaves()) { var save = saver.GetSave(saveName); if (save is null) { continue; } Console.WriteLine(); Console.WriteLine(Util.FormatResults(new Dictionary <int, List <Result> > { { 1, save.SingleThreadedResults },
private static void Main(string[] args) { var saver = new ResultSaver(); AppDomain.CurrentDomain.ProcessExit += (sender, eventArgs) => CurrentDomainOnProcessExit(sender, eventArgs, saver); Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.BelowNormal; var options = GetOptions(args); if (options is null) { return; } Console.WriteLine("Gathering hardware information..."); var information = MachineInformationGatherer.GatherInformation(); Console.WriteLine("OS: {0}", information.OperatingSystem); Console.WriteLine("Processor: {0}", information.Cpu.Name); Console.WriteLine("Architecture: {0}", information.Cpu.Architecture); Console.WriteLine("Logical Cores: {0}", information.Cpu.LogicalCores); Console.WriteLine("Physical Cores: {0}", information.Cpu.PhysicalCores); Console.WriteLine(); Console.WriteLine("Starting Benchmark..."); Console.WriteLine(); var runner = new Runner(options, new NullLogger <Runner>()); Console.WriteLine("Running the following benchmarks in approx. {1}: {0}", string.Join(", ", runner.GetBenchmarksToRun().Select(benchmark => benchmark.GetName())), Helper.FormatTime(runner.GetTotalTime())); Console.WriteLine(); Console.WriteLine(); using var ct = new CancellationTokenSource(); var t = new Thread(() => DisplayProgressbar(ref runner, ref options, ct.Token)); t.Start(); runner.RunBenchmarks(); ct.Cancel(); t.Join(); saver.CreateOrUpdateSaveForCurrentRun(information, runner.Results); var save = saver.GetSave("current"); if (save is null) { return; } Console.WriteLine(); Console.WriteLine( Util.FormatResults(new Dictionary <int, List <Result> > { { 1, save.SingleThreadedResults }, { Environment.ProcessorCount, save.MultiThreadedResults } })); Console.WriteLine(); }