HdrHistogramJS
HdrHistogramJS copied to clipboard
Expose iterators
I have a need to use a RecordedValuesIterator to access histogram values accumulated across multiple runs. From the implementation, it seems like there are separate implementations for WasmHistogram and JsHistogram, so maybe static methods on each ?
I would like this as well, for now I'm using it dynamically and using @ts-ignore:
export const getPercentiles = (histogram: Histogram) => {
const percentiles: PercentileResponse[] = [];
// @ts-ignore
const iterator = histogram.percentileIterator;
iterator.reset(5);
while (iterator.hasNext()) {
const iterationValue = iterator.next();
percentiles.push({
value: new Decimal(iterationValue.valueIteratedTo),
percentile: iterationValue.percentileLevelIteratedTo / 100,
totalCount: iterationValue.totalCountToThisValue,
});
}
return percentiles;
};