Exemplo n.º 1
0
        private static BenchmarkRunResult Run(BenchmarkRunConfiguration configuration)
        {
            var runs      = new List <ScenarioRunResult>();
            var stopwatch = new Stopwatch();

            var tests = typeof(Scenarios)
                        .GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly)
                        .ToArray();

            foreach (var methodInfo in tests)
            {
                var benchmark = new Scenarios(configuration.SearchParameters);

                stopwatch.Start();
                methodInfo.Invoke(benchmark, new object[] {});
                stopwatch.Stop();

                runs.Add(new ScenarioRunResult(
                             methodInfo.Name,
                             stopwatch.Elapsed));

                stopwatch.Reset();
            }

            return(new BenchmarkRunResult(configuration.Name, configuration.Description, runs));
        }
Exemplo n.º 2
0
        private static BenchmarkRunResult Run(BenchmarkRunConfiguration configuration)
        {
            var runs = new List<ScenarioRunResult>();
              var stopwatch = new Stopwatch();

              var tests = typeof (Scenarios)
            .GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly)
            .ToArray();

              foreach (var methodInfo in tests)
              {
            var benchmark = new Scenarios(configuration.SearchParameters);

            stopwatch.Start();
            methodInfo.Invoke(benchmark, new object[] {});
            stopwatch.Stop();

            runs.Add(new ScenarioRunResult(
              methodInfo.Name,
              stopwatch.Elapsed));

            stopwatch.Reset();
              }

              return new BenchmarkRunResult(configuration.Name, configuration.Description, runs);
        }
Exemplo n.º 3
0
        //[Fact]
        public void RunAndCompareWithXUnit()
        {
            var result = RunAndCompare(
                run: BenchmarkRunConfiguration.D60T2MT2(),
                compareTo: BenchmarkRunConfiguration.D40T2MT2());

            Console.WriteLine(result.PrettyPrint());
        }
Exemplo n.º 4
0
        public static BenchmarkResult RunAndCompare(BenchmarkRunConfiguration run,
                                                    BenchmarkRunConfiguration compareTo)
        {
            Asrt.True(File.Exists(compareTo.GetBenchmarkBaseFilename()),
                      "Benchmark recording file is missing! Please record a benchmark to compare to, before running a comparision.");

            var baseResults = BenchmarkRunResult.ReadFromFile(compareTo.GetBenchmarkBaseFilename());
            var results     = Run(run);

            return(new BenchmarkResult(results, baseResults));
        }
Exemplo n.º 5
0
        public static BenchmarkResult RunAndCompare(BenchmarkRunConfiguration run,
      BenchmarkRunConfiguration compareTo)
        {
            Asrt.True(File.Exists(compareTo.GetBenchmarkBaseFilename()),
            "Benchmark recording file is missing! Please record a benchmark to compare to, before running a comparision.");

              var baseResults = BenchmarkRunResult.ReadFromFile(compareTo.GetBenchmarkBaseFilename());
              var results = Run(run);

              return new BenchmarkResult(results, baseResults);
        }
Exemplo n.º 6
0
        //[Fact]
        public void RecordWithXUnit()
        {
            var configurations = new[]
            {
                //BenchmarkRunConfiguration.D40T2ST(),
                //BenchmarkRunConfiguration.D40T2MT1(),
                BenchmarkRunConfiguration.D40T2MT2(),
            };

            foreach (var configuration in configurations)
            {
                Record(configuration);
            }
        }
Exemplo n.º 7
0
        public static void Record(BenchmarkRunConfiguration configuration)
        {
            var results = Run(configuration);

            results.WriteToFile(configuration.GetBenchmarkBaseFilename());
        }
Exemplo n.º 8
0
 public static void Record(BenchmarkRunConfiguration configuration)
 {
     var results = Run(configuration);
       results.WriteToFile(configuration.GetBenchmarkBaseFilename());
 }