public SpecificBenchmarkRunner(
     IBenchmarkRunner runner,
     Type benchmarkContainerType)
 {
     this.runner         = runner;
     this.BenchmarkClass = benchmarkContainerType;
 }
예제 #2
0
        public static BenchmarkResults RunBenchmark <TBenchmarkContainer>(
            this IBenchmarkRunner runner,
            IEnumerable <ISampleSizeDeterminer> forSampleSizeDeterminers)
        {
            var estimate = runner.GetRunEstimate <TBenchmarkContainer>(forSampleSizeDeterminers);

            return(runner.RunBenchmark <TBenchmarkContainer>(estimate.RunParameters));
        }
예제 #3
0
        public static ISpecificBenchmarkRunner For <TContainerBaseline, TContainerTreatment>(
            this IBenchmarkRunner runner,
            Expression <Action <TContainerBaseline> > baseline,
            Expression <Action <TContainerTreatment> > treatment)
        {
            ValidateForMethodPreconditions(baseline, treatment);

            var baselineMethod  = ((MethodCallExpression)baseline.Body).Method;
            var treatmentMethod = ((MethodCallExpression)treatment.Body).Method;

            var type = baselineMethod.DeclaringType;

            var methodInfo = typeof(BenchmarkRunnerExtensions).GetMethod(nameof(ForBenchmarkContainer));
            var gen        = methodInfo.MakeGenericMethod(type);

            object target = null; // Because it's static

            return((ISpecificBenchmarkRunner)gen.Invoke(target, new object[] { runner }));
        }
예제 #4
0
 public static ISpecificBenchmarkRunner ForBenchmarkContainer <TBenchmarkContainer>(
     this IBenchmarkRunner runner)
 {
     return(new SpecificBenchmarkRunner(runner, typeof(TBenchmarkContainer)));
 }