Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose iterators #27

Open
ccollie opened this issue Dec 11, 2020 · 1 comment
Open

Expose iterators #27

ccollie opened this issue Dec 11, 2020 · 1 comment

Comments

@ccollie
Copy link

ccollie commented Dec 11, 2020

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 ?

@peroxy
Copy link

peroxy commented Mar 1, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants