Atomic counter class used for incrementing and decrementing long integer values.
        /// <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);
        }
Example #2
0
 internal Counter(AtomicCounter internalCounter, CounterMetricName name)
 {
     _internalCounter = internalCounter;
     Name = name;
 }
 public CounterMetricCollector(MetricName name, AtomicCounter counter)
     : this(name, MetricNames.CounterUnits, counter)
 {
 }
 public CounterMetricCollector(MetricName name, string unitName, AtomicCounter counter) : base(name, unitName)
 {
     _counter = counter;
 }
 public CreateCounterBenchmarkSetting(CounterBenchmarkSetting benchmarkSetting, AtomicCounter counter)
 {
     BenchmarkSetting = benchmarkSetting;
     Counter = counter;
 }