Esempio n. 1
0
        public void ShouldDisposeAllCounters()
        {
            var testCollector1 = new TestMetricCollector(new CounterMetricName("foo"), "bar");
            var measureBucket1 = new MeasureBucket(testCollector1);

            var testCollector2 = new TestMetricCollector(new CounterMetricName("foo"), "bar");
            var measureBucket2 = new MeasureBucket(testCollector2);
            var benchmarkRun   = new BenchmarkRun(new List <MeasureBucket>(new[] { measureBucket1, measureBucket2 }),
                                                  new List <Counter>());

            Assert.False(testCollector1.WasDisposed);
            Assert.False(testCollector2.WasDisposed);

            benchmarkRun.Dispose();

            Assert.True(testCollector1.WasDisposed);
            Assert.True(testCollector2.WasDisposed);
        }
Esempio n. 2
0
        /// <summary>
        /// Complete the current run
        /// </summary>
        private void Complete()
        {
            _currentRun.Dispose();

            var report = _currentRun.ToReport(StopWatch.Elapsed);

            Output.WriteRun(report, _isWarmup);

            // Change runs, but not on warmup
            if (!_isWarmup)
            {
                // Decrease the number of pending iterations
                _pendingIterations--;


                CompletedRuns.Enqueue(report);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Complete the current run
        /// </summary>
        private void Complete(bool isEstimate = false)
        {
            _currentRun.Dispose();
            Trace.Info($"Generating report for {PrintWarmupOrRun(_isWarmup)} {1 + Settings.NumberOfIterations - _pendingIterations} of {BenchmarkName}");
            var report = _currentRun.ToReport(StopWatch.Elapsed);

            if (!isEstimate)
            {
                Output.WriteRun(report, _isWarmup);
            }

            // Change runs, but not on warmup
            if (!_isWarmup)
            {
                // Decrease the number of pending iterations
                _pendingIterations--;


                CompletedRuns.Enqueue(report);
            }
        }