Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/glentiki/hdr-histogram-percentiles-obj
A little lib for turning native-hdr-histograms to objects
https://github.com/glentiki/hdr-histogram-percentiles-obj
Last synced: 37 minutes ago
JSON representation
A little lib for turning native-hdr-histograms to objects
- Host: GitHub
- URL: https://github.com/glentiki/hdr-histogram-percentiles-obj
- Owner: GlenTiki
- License: mit
- Created: 2016-07-14T15:14:25.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-09-09T14:35:12.000Z (over 4 years ago)
- Last Synced: 2024-10-23T12:31:54.549Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 73.2 KB
- Stars: 11
- Watchers: 4
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# hdr-histogram-percentiles-obj
## Install
```
npm install --save hdr-histogram-percentiles-obj
```## Usage
```js
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])
})
```## API
hdr-histogram-percentiles-obj has two utility functions to use
### histAsObj(histogram, total)
* `histogram`: A hdr-histogram-js object you want to get some values from in a js object
* `total`: the total amount recorded by the histogram, optionalReturns a json object with the `min`, `max`, `average` (mean) and `stddev`
### addPercentiles(histogram, histAsObjResult)
* `histogram`: A hdr-histogram-js object you want to retrieve the percentiles from
* `histAsObjResult`: 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`.
### percentiles
An array listing the percentiles that hdr-histogram-percentiles-obj adds, as numbers.
## Sponsor
Kindly sponsored by [nearForm](www.nearform.com)
## License
[MIT](./LICENSE)