$ gnpm install hdr-histogram-percentiles-obj
npm install --save hdr-histogram-percentiles-obj
const histPercentileObj = require('hdr-histogram-percentiles-obj')
const Histogram = require('hdr-histogram-js')
const histogram = hdr.build({
lowestDiscernibleValue: 1,
highestTrackableValue: 100
})
const total = 0
// record some histogram data...
// total++...
const result = histPercentileObj.histAsObj(histogram, total)
const resultWithPercentiles = histPercentileObj.addPercentiles(histogram, histPercentileObj.histAsObj(histogram, total))
histPercentileObj.percentiles.forEach((p) => {
const key = `p${p}`.replace('.', '_')
console.log(`${p}%`, resultWithPercentiles[key])
})
hdr-histogram-percentiles-obj has two utility functions to use
histogram: A hdr-histogram-js object you want to get some values from in a js objecttotal: the total amount recorded by the histogram, optionalReturns a json object with the min, max, average (mean) and stddev
histogram: A hdr-histogram-js object you want to retrieve the percentiles fromhistAsObjResult: the result returned when histAsObj is called on some hdr-histogram-js objectReturns the histAsObjResult with the percentiles properties added. Percentile properties are named pNN_DD, for the NN.DD% percentile. Eg., the 99th percentile is p99, while the 99.99th percentile is p99_99.
An array listing the percentiles that hdr-histogram-percentiles-obj adds, as numbers.
Kindly sponsored by nearForm
Copyright 2013 - present © cnpmjs.org | Home |