Esempio n. 1
0
 public void TimerMetric_CanCount()
 {
     timer.Value.Rate.Count.Should().Be(0);
     using (timer.NewContext()) { }
     timer.Value.Rate.Count.Should().Be(1);
     using (timer.NewContext()) { }
     timer.Value.Rate.Count.Should().Be(2);
     timer.Time(() => { });
     timer.Value.Rate.Count.Should().Be(3);
     timer.Time(() => 1);
     timer.Value.Rate.Count.Should().Be(4);
 }
Esempio n. 2
0
 public void TimerCanCount()
 {
     TimerMetric timer = new TimerMetric();
     timer.Value.Rate.Count.Should().Be(0);
     using (timer.NewContext()) { }
     timer.Value.Rate.Count.Should().Be(1);
     using (timer.NewContext()) { }
     timer.Value.Rate.Count.Should().Be(2);
     timer.Time(() => { });
     timer.Value.Rate.Count.Should().Be(3);
     timer.Time(() => 1);
     timer.Value.Rate.Count.Should().Be(4);
 }
Esempio n. 3
0
        public void TimerCanTrackTime()
        {
            TestClock clock = new TestClock();
            TestScheduler scheduler = new TestScheduler(clock);

            TimerMetric timer = new TimerMetric(SamplingType.LongTerm, new MeterMetric(clock, scheduler), clock);
            using (timer.NewContext())
            {
                clock.Advance(TimeUnit.Milliseconds, 100);
            }
            timer.Value.Histogram.Count.Should().Be(1);
            timer.Value.Histogram.Max.Should().Be(TimeUnit.Milliseconds.ToNanoseconds(100));
        }
Esempio n. 4
0
        public void TimerCanTrackTime()
        {
            TestClock     clock     = new TestClock();
            TestScheduler scheduler = new TestScheduler(clock);

            TimerMetric timer = new TimerMetric(SamplingType.LongTerm, new MeterMetric(clock, scheduler), clock);

            using (timer.NewContext())
            {
                clock.Advance(TimeUnit.Milliseconds, 100);
            }
            timer.Value.Histogram.Count.Should().Be(1);
            timer.Value.Histogram.Max.Should().Be(TimeUnit.Milliseconds.ToNanoseconds(100));
        }
Esempio n. 5
0
        public void TimerContextRecordsTimeOnlyOnFirstDispose()
        {
            TestClock clock = new TestClock();
            TestScheduler scheduler = new TestScheduler(clock);

            TimerMetric timer = new TimerMetric(SamplingType.LongTerm, new MeterMetric(clock, scheduler), clock);

            var context = timer.NewContext();
            clock.Advance(TimeUnit.Milliseconds, 100);
            using (context) { }
            clock.Advance(TimeUnit.Milliseconds, 100);
            using (context) { }

            timer.Value.Histogram.Count.Should().Be(1);
            timer.Value.Histogram.Max.Should().Be(TimeUnit.Milliseconds.ToNanoseconds(100));
        }
Esempio n. 6
0
        public void TimerContextRecordsTimeOnlyOnFirstDispose()
        {
            TestClock     clock     = new TestClock();
            TestScheduler scheduler = new TestScheduler(clock);

            TimerMetric timer = new TimerMetric(SamplingType.LongTerm, new MeterMetric(clock, scheduler), clock);

            var context = timer.NewContext();

            clock.Advance(TimeUnit.Milliseconds, 100);
            using (context) { }
            clock.Advance(TimeUnit.Milliseconds, 100);
            using (context) { }

            timer.Value.Histogram.Count.Should().Be(1);
            timer.Value.Histogram.Max.Should().Be(TimeUnit.Milliseconds.ToNanoseconds(100));
        }
Esempio n. 7
0
 public void can_count()
 {
     _timer.Value.Rate.Count.Should().Be(0);
     using (_timer.NewContext())
     {
     }
     _timer.Value.Rate.Count.Should().Be(1);
     using (_timer.NewContext())
     {
     }
     _timer.Value.Rate.Count.Should().Be(2);
     _timer.Time(() => { });
     _timer.Value.Rate.Count.Should().Be(3);
     _timer.Time(() => 1);
     _timer.Value.Rate.Count.Should().Be(4);
 }