GlobalPerf() { Hardware = new Lazy <HardwareInfo>(() => new HardwareInfo(sink)); blobReadBytes = rates.GetOrAdd("blob_read_bytes", new MultiIntervalStats(Intervals)); blobReadEvents = rates.GetOrAdd("blob_reads", new MultiIntervalStats(Intervals)); jobs = rates.GetOrAdd("jobs_completed", new MultiIntervalStats(Intervals)); decodedPixels = rates.GetOrAdd("decoded_pixels", new MultiIntervalStats(Intervals)); encodedPixels = rates.GetOrAdd("encoded_pixels", new MultiIntervalStats(Intervals)); job_times = percentiles.GetOrAdd("job_times", new TimingsSink()); decode_times = percentiles.GetOrAdd("decode_times", new TimingsSink()); encode_times = percentiles.GetOrAdd("encode_times", new TimingsSink()); job_other_time = percentiles.GetOrAdd("job_other_time", new TimingsSink()); blob_read_times = percentiles.GetOrAdd("blob_read_times", new TimingsSink()); collect_info_times = percentiles.GetOrAdd("collect_info_times", new TimingsSink()); sourceMegapixels = percentiles.GetOrAdd("source_pixels", new PixelCountSink()); outputMegapixels = percentiles.GetOrAdd("output_pixels", new PixelCountSink()); sourceWidths = percentiles.GetOrAdd("source_width", new ResolutionsSink()); sourceHeights = percentiles.GetOrAdd("source_height", new ResolutionsSink()); outputWidths = percentiles.GetOrAdd("output_width", new ResolutionsSink()); outputHeights = percentiles.GetOrAdd("output_height", new ResolutionsSink()); scalingRatios = percentiles.GetOrAdd("scaling_ratio", new FlatSink(1000)); sourceAspectRatios = percentiles.GetOrAdd("source_aspect_ratio", new FlatSink(1000)); outputAspectRatios = percentiles.GetOrAdd("output_aspect_ratio", new FlatSink(1000)); }
public void TestRates() { var time = new TimeProvider(); var r = new MultiIntervalStats( new[] { new NamedInterval { Name = "per second", TicksDuration = Stopwatch.Frequency, Unit = "second" } }, time.GetTimestamp); time.Timestamp = Stopwatch.Frequency * 2; Assert.True(r.Record(Stopwatch.Frequency + 10, 10)); Assert.True(r.Record(Stopwatch.Frequency + 30, 10)); Assert.True(r.Record(Stopwatch.Frequency + 10, 10)); time.Timestamp = Stopwatch.Frequency * 3; Assert.True(r.Record(Stopwatch.Frequency * 2 + 1, 20)); Assert.True(r.Record(Stopwatch.Frequency * 3 + 1, 10)); time.Timestamp = Stopwatch.Frequency * 10; Assert.True(r.Record(Stopwatch.Frequency * 9 + 1, 10)); Assert.Equal(70, r.RecordedTotal); var stat = r.GetStats().First(); Assert.Equal(0, stat.Min); //we skipped buckets // Assert.Equal(14, stat.Avg); //TODO: fix, unstable results, should not occur! Assert.Equal(30, stat.Max); }
public void MultiIntervalTest() { NamedInterval[] Intervals = { new NamedInterval { Unit = "second", Name = "Per Second", TicksDuration = Stopwatch.Frequency }, new NamedInterval { Unit = "minute", Name = "Per Minute", TicksDuration = Stopwatch.Frequency * 60 }, new NamedInterval { Unit = "15_mins", Name = "Per 15 Minutes", TicksDuration = Stopwatch.Frequency * 60 * 15 }, new NamedInterval { Unit = "hour", Name = "Per Hour", TicksDuration = Stopwatch.Frequency * 60 * 60 }, }; var s = new MultiIntervalStats(Intervals); for (long i = Stopwatch.Frequency * -1000; i < Stopwatch.Frequency * 5000; i += Stopwatch.Frequency / 2) { s.Record(i, 1); } }