source: trip-planner-front/node_modules/hdr-histogram-percentiles-obj/readme.md@ 76712b2

Last change on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.7 KB
Line 
1# hdr-histogram-percentiles-obj
2
3## Install
4
5```
6npm install --save hdr-histogram-percentiles-obj
7```
8
9## Usage
10
11```js
12const histPercentileObj = require('hdr-histogram-percentiles-obj')
13const Histogram = require('hdr-histogram-js')
14
15const histogram = hdr.build({
16 lowestDiscernibleValue: 1,
17 highestTrackableValue: 100
18})
19const total = 0
20// record some histogram data...
21// total++...
22
23const result = histPercentileObj.histAsObj(histogram, total)
24const resultWithPercentiles = histPercentileObj.addPercentiles(histogram, histPercentileObj.histAsObj(histogram, total))
25histPercentileObj.percentiles.forEach((p) => {
26 const key = `p${p}`.replace('.', '_')
27 console.log(`${p}%`, resultWithPercentiles[key])
28})
29```
30
31## API
32
33hdr-histogram-percentiles-obj has two utility functions to use
34
35### histAsObj(histogram, total)
36
37* `histogram`: A hdr-histogram-js object you want to get some values from in a js object
38* `total`: the total amount recorded by the histogram, optional
39
40Returns a json object with the `min`, `max`, `average` (mean) and `stddev`
41
42### addPercentiles(histogram, histAsObjResult)
43
44* `histogram`: A hdr-histogram-js object you want to retrieve the percentiles from
45* `histAsObjResult`: the result returned when `histAsObj` is called on some hdr-histogram-js object
46
47Returns 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`.
48
49### percentiles
50
51An array listing the percentiles that hdr-histogram-percentiles-obj adds, as numbers.
52
53## Sponsor
54
55Kindly sponsored by [nearForm](www.nearform.com)
56
57## License
58
59[MIT](./LICENSE)
Note: See TracBrowser for help on using the repository browser.