public void BucketizationOfAggregationSets() { var propertyValues = new string[] { "Value1", "Value2", "Value3", "Value4", "Value5", null, "Value6" }; const int seedValue = 50; const int iterations = 50; var client = new TelemetryClient(); var perfCollector = new PerfCollector(this.TestContext); for (int i = 1; i <= iterations; i++) { for (int p1 = 0; p1 < propertyValues.Count(); p1++) { for (int p2 = 0; p2 < propertyValues.Count(); p2++) { for (int p3 = 0; p3 < propertyValues.Count(); p3++) { client.TrackAggregateMetric("My Counter", seedValue * i, propertyValues[p1], propertyValues[p2], propertyValues[p3]); } } } } Assert.AreEqual(1, AggregateMetrics.aggregationSets.Count); perfCollector.StopAndSubmitPerfData(); AggregationSet aggregationSet; AggregateMetrics.aggregationSets.TryGetValue(AggregateMetrics.aggregationSets.Keys.First(), out aggregationSet); Assert.AreEqual(5, aggregationSet.property1Values.Count); Assert.AreEqual(5, aggregationSet.property2Values.Count); Assert.AreEqual(5, aggregationSet.property3Values.Count); var aggregations = aggregationSet.RemoveAggregations(); Assert.AreEqual((Constants.MaxPropertyCardinality + 2) * (Constants.MaxPropertyCardinality + 2) * (Constants.MaxPropertyCardinality + 2), aggregations.Count); foreach (MetricsBag counter in aggregations.Values) { Assert.AreEqual(iterations, counter.CalculateAggregation().Count); Assert.AreEqual(seedValue * (iterations + 1) / 2, counter.CalculateAggregation().Average); } }
public void CalculateAggregationPerformanceWithPercentiles() { var counterData = new MetricsBag(); const int iterations = 10000000; for (int i = 0; i < iterations; i++) { counterData.Add(i); } var perfCollector = new PerfCollector(this.TestContext); AggregationResult agg = counterData.CalculateAggregation(); perfCollector.StopAndSubmitPerfData(); Assert.AreEqual(iterations, agg.Count); }