예제 #1
0
        public static BenchmarkScenarioResult Run <TNode>(
            BenchmarkScenario <TNode> scenario, ILevelGeneratorFactory <TNode> levelGeneratorFactory, int repeats, Legacy.Benchmarks.BenchmarkOptions options = null)
        {
            if (options == null)
            {
                options = new Legacy.Benchmarks.BenchmarkOptions();
            }

            var benchmarkJobs = new List <BenchmarkJob>();
            var benchmark     = options.MultiThreaded
                ? new BenchmarkUtils.MultiThreadedBenchmark <BenchmarkJob, BenchmarkJobResult>(options.MaxDegreeOfParallelism)
                : new BenchmarkUtils.Benchmark <BenchmarkJob, BenchmarkJobResult>();

            benchmark.SetConsoleOutput(options.WithConsoleOutput, options.WithConsolePreview);

            // TODO: this should be more configurable
            if (options.WithFileOutput)
            {
                benchmark.AddFileOutput();
            }

            foreach (var input in scenario.LevelDescriptions)
            {
                var runner = levelGeneratorFactory.GetGeneratorRunner(input);

                benchmarkJobs.Add(new BenchmarkJob(runner, input.Name, repeats, 0.8));
            }

            var benchmarkJobResults = benchmark.Run(benchmarkJobs.ToArray(), $"{scenario.Name} - {levelGeneratorFactory.Name}");

            return(new BenchmarkScenarioResult($"{scenario.Name} - {levelGeneratorFactory.Name}",
                                               benchmarkJobResults.Select(x => new BenchmarkResult(x.InputName, x.Runs.ToList())).ToList()));
        }
예제 #2
0
        protected virtual BenchmarkScenarioResult RunBenchmark <TNode>(BenchmarkScenario <TNode> scenario, ILevelGeneratorFactory <TNode> generator, int iterations)
        {
            var scenarioResult = BenchmarkRunner.Run(scenario, generator, iterations, new Legacy.Benchmarks.BenchmarkOptions()
            {
                WithConsolePreview     = Options.WithConsolePreview,
                MultiThreaded          = Options.MaxThreads > 1,
                MaxDegreeOfParallelism = Options.MaxThreads,
                WithFileOutput         = false,
            });

            var resultSaver = new BenchmarkResultSaver();

            resultSaver.SaveResultDefaultLocation(scenarioResult, directory: DirectoryFullPath, name: $"{Directory}_{scenario.Name}_{generator.Name}", withDatetime: false);

            return(scenarioResult);
        }
예제 #3
0
 public BenchmarkScenarioResult(BenchmarkScenario <TNode> benchmarkScenario, List <LevelDescriptionResult> levelDescriptionResults)
 {
     BenchmarkScenario       = benchmarkScenario;
     LevelDescriptionResults = levelDescriptionResults;
 }