public void TimeIntervalCollectionAcceptance()
        {
            var collection = new TimeIntervalCollection();
            Assert.Equal(0, collection.Count);

            collection.AddIntervals("i1");
            collection.AddIntervals("i2");
            Assert.Equal(2, collection.GetIntervalsCount());

            var ti = new TimeInterval();
            ti.Start();
            ti.Stop();

            collection.AddInterval("i1", ti);
            collection.AddInterval("i2", ti);

            collection.AddInterval("i3", ti);
            collection.AddInterval("i3", ti);

            var i3 = collection.GetIntervals("i3").ToList();
            Assert.Equal(2, i3.Count);

            collection.Reset("i3");
            i3 = collection.GetIntervals("i3").ToList();
            Assert.Equal(0, i3.Count);
        }
 public override void ReportTimer(string name, TimeInterval interval, TimeUnit resolution)
 {
     {
         this.callback(string.Format(@"Timer. Name:{0}. Start:{1}. End:{2}. Duration:{3}/n"
             , name
             , TimeUnit.Nanoseconds.Convert(resolution, interval.StartTime)
             , TimeUnit.Nanoseconds.Convert(resolution, interval.EndTime)
             , TimeUnit.Nanoseconds.Convert(resolution, interval.Duration)));
     }
 }
 private long GenerateIntervals(MetricsService metrics, string name)
 {
     var r = new Random();
     long cycles = 50 + r.Next() % 200;
     if (cycles % 2 == 1) cycles++;
     Enumerable.Range(1, (int)cycles).ToList()
         .ForEach(x =>
         {
             var ti = new TimeInterval();
             ti.Start();
             Thread.Sleep(10);
             ti.Stop();
             metrics.Intervals.AddInterval(name, ti);
         });
     return cycles;
 }
 public override void ReportTimer(string name, TimeInterval value, TimeUnit resolution)
 {
 }
 public abstract void ReportTimer(string name, TimeInterval value, TimeUnit resolution);