HdrHistogramJS icon indicating copy to clipboard operation
HdrHistogramJS copied to clipboard

Expose iterators

Open ccollie opened this issue 5 years ago • 1 comments

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 ?

ccollie avatar Dec 11 '20 19:12 ccollie

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;
};

peroxy avatar Mar 01 '22 10:03 peroxy