Beispiel #1
0
        public void MeasureBucketShouldDisposeCollector()
        {
            var testCollector = new TestMetricCollector(new CounterMetricName("foo"), "bar");
            var measureBucket = new MeasureBucket(testCollector);

            Assert.False(measureBucket.WasDisposed);
            Assert.False(testCollector.WasDisposed);
            measureBucket.Dispose();
            Assert.True(measureBucket.WasDisposed);
            Assert.True(testCollector.WasDisposed);
        }
Beispiel #2
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);
        }
Beispiel #3
0
        [InlineData(new long[] {}, new long[] {})] // no collections
        public void MeasureBucketShouldProduceReport(long[] msValues, long[] counterValues)
        {
            var testCollector = new TestMetricCollector(new CounterMetricName("foo"), "bar");
            var measureBucket = new MeasureBucket(testCollector);
            var length        = msValues.Length;
            var timeSpans     = msValues.Select(x => TimeSpan.FromMilliseconds(x).Ticks).ToList();

            for (var i = 0; i < length; i++)
            {
                testCollector.CollectorValue = counterValues[i];
                measureBucket.Collect(timeSpans[i]);
            }

            var delta  = counterValues.LastOrDefault() - counterValues.FirstOrDefault();
            var report = measureBucket.ToReport();

            Assert.Equal(delta, report.MetricValue);
        }