/// <summary>
        ///     Generates a new <see cref="BenchmarkRun" /> based on the provided settings, available system metrics,
        ///     and (optionally) the duration of the last run.
        /// </summary>
        /// <param name="warmupData">Data collected during warm-up</param>
        /// <returns>A new <see cref="BenchmarkRun" /> instance.</returns>
        public BenchmarkRun NewRun(WarmupData warmupData)
        {
            var numberOfMetrics = Settings.TotalTrackedMetrics;
            var measurements    = new List <MeasureBucket>(numberOfMetrics);
            var counterSettings = Settings.CounterMeasurements.ToList();
            var counters        = new List <Counter>(counterSettings.Count);

            // need to exclude counters first
            var settingsExceptCounters = Settings.DistinctMeasurements.Except(counterSettings);

            foreach (var setting in settingsExceptCounters)
            {
                var selector  = Settings.Collectors[setting.MetricName];
                var collector = selector.Create(Settings.RunMode, warmupData, setting);
                measurements.Add(new MeasureBucket(collector));
            }

            foreach (var counterSetting in counterSettings)
            {
                var setting                = counterSetting;
                var selector               = Settings.Collectors[setting.MetricName];
                var atomicCounter          = new AtomicCounter();
                var createCounterBenchmark = new CreateCounterBenchmarkSetting(setting, atomicCounter);
                var collector              = selector.Create(Settings.RunMode, warmupData, createCounterBenchmark);

                measurements.Add(new MeasureBucket(collector));
                counters.Add(new Counter(atomicCounter, setting.CounterName));
            }

            return(new BenchmarkRun(measurements, counters, Settings.Trace));
        }
Exemple #2
0
        /// <summary>
        ///     Generates a new <see cref="BenchmarkRun" /> based on the provided settings, available system metrics,
        ///     and (optionally) the duration of the last run.
        /// </summary>
        /// <param name="warmupData">Data collected during warm-up</param>
        /// <returns>A new <see cref="BenchmarkRun" /> instance.</returns>
        public BenchmarkRun NewRun(WarmupData warmupData)
        {
            var numberOfMetrics = Settings.TotalTrackedMetrics;
            var measurements    = new List <MeasureBucket>(numberOfMetrics);
            var counters        = new List <Counter>(Settings.CounterBenchmarks.Count);

            for (var i = 0; i < Settings.DistinctMemoryBenchmarks.Count; i++)
            {
                var setting    = Settings.DistinctMemoryBenchmarks[i];
                var collectors = MemorySelectors[setting.Metric].Create(Settings.RunMode, warmupData, setting);
                foreach (var collector in collectors)
                {
                    measurements.Add(new MeasureBucket(collector));
                }
            }

            for (var i = 0; i < Settings.DistinctGcBenchmarks.Count; i++)
            {
                var setting    = Settings.DistinctGcBenchmarks[i];
                var collectors = GcSelectors[setting.Metric].Create(Settings.RunMode, warmupData, setting);
                foreach (var collector in collectors)
                {
                    measurements.Add(new MeasureBucket(collector));
                }
            }

            for (var i = 0; i < Settings.DistinctCounterBenchmarks.Count; i++)
            {
                var setting                = Settings.DistinctCounterBenchmarks[i];
                var atomicCounter          = new AtomicCounter();
                var createCounterBenchmark = new CreateCounterBenchmarkSetting(setting, atomicCounter);
                var collectors             = CounterSelector.Create(Settings.RunMode, warmupData, createCounterBenchmark);
                foreach (var collector in collectors)
                {
                    measurements.Add(new MeasureBucket(collector));
                    counters.Add(new Counter(atomicCounter, setting.CounterName));
                }
            }

            return(new BenchmarkRun(measurements, counters));
        }
        /// <summary>
        ///     Generates a new <see cref="BenchmarkRun" /> based on the provided settings, available system metrics,
        ///     and (optionally) the duration of the last run.
        /// </summary>
        /// <param name="warmupData">Data collected during warm-up</param>
        /// <returns>A new <see cref="BenchmarkRun" /> instance.</returns>
        public BenchmarkRun NewRun(WarmupData warmupData)
        {
            var numberOfMetrics = Settings.TotalTrackedMetrics;
            var measurements = new List<MeasureBucket>(numberOfMetrics);
            var counters = new List<Counter>(Settings.CounterBenchmarks.Count);

            for (var i = 0; i < Settings.DistinctMemoryBenchmarks.Count; i++)
            {
                var setting = Settings.DistinctMemoryBenchmarks[i];
                var collectors = MemorySelectors[setting.Metric].Create(Settings.RunMode, warmupData, setting);
                foreach (var collector in collectors)
                    measurements.Add(new MeasureBucket(collector));
            }

            for (var i = 0; i < Settings.DistinctGcBenchmarks.Count; i++)
            {
                var setting = Settings.DistinctGcBenchmarks[i];
                var collectors = GcSelectors[setting.Metric].Create(Settings.RunMode, warmupData, setting);
                foreach (var collector in collectors)
                    measurements.Add(new MeasureBucket(collector));
            }

            for (var i = 0; i < Settings.DistinctCounterBenchmarks.Count; i++)
            {
                var setting = Settings.DistinctCounterBenchmarks[i];
                var atomicCounter = new AtomicCounter();
                var createCounterBenchmark = new CreateCounterBenchmarkSetting(setting, atomicCounter);
                var collectors = CounterSelector.Create(Settings.RunMode, warmupData, createCounterBenchmark);
                foreach (var collector in collectors)
                {
                    measurements.Add(new MeasureBucket(collector));
                    counters.Add(new Counter(atomicCounter, setting.CounterName));
                }
            }

            return new BenchmarkRun(measurements, counters);
        }