HdrHistogram.NET icon indicating copy to clipboard operation
HdrHistogram.NET copied to clipboard

Consistent index error on Windows

Open kqr opened this issue 6 years ago • 1 comments

When initialising the following LongHistogram

var measurements = new LongHistogram((long) TimeSpan.FromMinutes(15).TotalMilliseconds, 3);

and then in a continuous loop add measurements to it with

measurements.RecordValue(actual - expected);

I consistently get the following exception:

 Index was outside the bounds of the array.
Stack Trace:
   at HdrHistogram.Utilities.Bitwise.Log2(Int32 i)
   at HdrHistogram.Utilities.Bitwise.NumberOfLeadingZeros(Int64 value)
   at HdrHistogram.HistogramBase.RecordSingleValue(Int64 value)

Could this be because actual - expected can be negative – or 0? I had assumed HdrHistogram handled that, but I realise now I might have been incorrect.

kqr avatar Nov 05 '19 07:11 kqr

That was indeed the case. Maybe there should be a better exception thrown in that case? Or is there a reason not to do that?

kqr avatar Nov 05 '19 08:11 kqr