A bug in Histogram?
I was looking around the source code and the following piece of code seems a bit buggy to me:
https://github.com/microsoft/perfview/blob/c671d460fdd4abd915a96beb1410c8c7748432fb/src/TraceEvent/Stacks/Histogram.cs#L48-L68
Let's say the following sequence of AddMetric is called:
AddMetric(1.0f, 0);
AddMetric(2.0f, 1);
AddMetric(3.0f, 0);
The second time will cause the array to be constructed, and m_singleBucketValue is populated into the array.
But within the third call, if (m_singleBucketNum == bucket) will still be true, and the metric is still added into m_singleBucketValue instead of the array.
Inside the indexer:
https://github.com/microsoft/perfview/blob/c671d460fdd4abd915a96beb1410c8c7748432fb/src/TraceEvent/Stacks/Histogram.cs#L119-L126
the m_singleBucketValue isn't used when the array is not null, causing the entry for m_singleBucketNum to be returned with incorrected value.
I don't have the whole knowledge of how Histogram is used, so I don't sure if this is really a bug. And this problem might not be a big issue due to the usage pattern, cause I don't see any bucket to be obviously wrong in the GUI.