public void TestLogarithmicBucketValues() { var index = 0; // Iterate raw data using logarithmic buckets starting at 10 msec. foreach (var v in RawHistogram.LogarithmicBucketValues(10000, 2)) { var countAddedInThisBucket = v.CountAddedInThisIterationStep; if (index == 0) { Assert.AreEqual(10000, countAddedInThisBucket, "Raw Logarithmic 10 msec bucket # 0 added a count of 10000"); } else if (index == 14) { Assert.AreEqual(1, countAddedInThisBucket, "Raw Logarithmic 10 msec bucket # 14 added a count of 1"); } else { Assert.AreEqual(0, countAddedInThisBucket, "Raw Logarithmic 100 msec bucket # " + index + " added a count of 0"); } index++; } Assert.AreEqual(14, index - 1); index = 0; long totalAddedCounts = 0; // Iterate data using linear buckets of 1 sec each. foreach (var v in LongHistogram.LogarithmicBucketValues(10000, 2)) { var countAddedInThisBucket = v.CountAddedInThisIterationStep; if (index == 0) { Assert.AreEqual(10001, countAddedInThisBucket, $"Logarithmic 10 msec bucket # 0 [{v.ValueIteratedFrom}..{v.ValueIteratedTo}] added a count of 10001"); } totalAddedCounts += v.CountAddedInThisIterationStep; index++; } Assert.AreEqual(14, index - 1, "There should be 14 Logarithmic buckets of size 10000 usec between 0 and 100 sec."); Assert.AreEqual(20000, totalAddedCounts, "Total added counts should be 20000"); }