Пример #1
0
 private BenchmarkRunner(BenchmarkServiceConfiguration configuration, IScoringStrategy scoringStrategy)
 {
     this.configuration   = configuration;
     this.scoringStrategy = scoringStrategy;
     this.testValues      = BenchmarkRunner.GetTestValues(new Random(this.configuration.Seed), this.configuration.Operations.Sum(kvp => kvp.Value) * this.configuration.TestIterationCountScalar);
     this.stopWatch       = new Stopwatch();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="BenchmarkService" /> class.
 /// </summary>
 /// <param name="configuration">The configuration.</param>
 /// <param name="scoringStrategy">The scoring strategy.</param>
 private BenchmarkService(BenchmarkServiceConfiguration configuration, IScoringStrategy scoringStrategy)
 {
     this.configuration = configuration;
     this.generator     = new Random(this.configuration.Seed);
     this.data          = this.GetData(this.configuration.Cardinalities.Max());
     this.runner        = BenchmarkRunner.Create(configuration, scoringStrategy);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="BenchmarkServiceConfiguration"/> class.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        private BenchmarkServiceConfiguration(IConfiguration configuration)
        {
            BenchmarkSettingsSection benchmarkSettings = configuration.GetSection(BenchmarkSettingsSection.SectionName)
                                                         .Get <BenchmarkSettingsSection>();

            BenchmarkServiceConfiguration.Validate(benchmarkSettings);

            this.Cardinalities  = benchmarkSettings.CardinalityPowers.Select(BenchmarkServiceConfiguration.GetCardinalityFromPower);
            this.ContainerTypes = benchmarkSettings.ContainerTypes;
            this.Seed           = benchmarkSettings.Seed;
            this.Operations     = benchmarkSettings.Operations;
        }
Пример #4
0
 /// <summary>
 /// Creates the specified benchmark runner.
 /// </summary>
 /// <param name="configuration">The configuration.</param>
 /// <param name="scoringStrategy">The scoring strategy.</param>
 /// <returns>
 /// A benchmark runner
 /// </returns>
 public static BenchmarkRunner Create(BenchmarkServiceConfiguration configuration, IScoringStrategy scoringStrategy)
 {
     return(new BenchmarkRunner(configuration, scoringStrategy));
 }
 /// <summary>
 /// Creates a benchmark service.
 /// </summary>
 /// <returns>A benchmark service</returns>
 public static BenchmarkService Create(BenchmarkServiceConfiguration configuration)
 {
     return(new BenchmarkService(configuration, new SimpleScoringStrategy()));
 }