Skip to content

Commit

Permalink
Drop native-hdr-histogram and add percentiles in docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
goto-bus-stop committed Jul 20, 2018
1 parent d590bd9 commit 3ccbf23
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,7 @@
npm install --save hdr-histogram-percentiles-obj
```

## Usage with native-hdr-histogram

```js
const histPercentileObj = require('hdr-histogram-percentiles-obj')
const Histogram = require('native-hdr-histogram')

const histogram = new Histogram(1, 100)
const total = 0
// record some histogram data...
// total++...

const result = histPercentileObj.histAsObj(histogram, total)
const resultWithPercentiles = histPercentileObj.addPercentiles(histogram, histPercentileObj.histAsObj(histogram, total))
```

## Usage with hdr-histogram-js
## Usage

```js
const histPercentileObj = require('hdr-histogram-percentiles-obj')
Expand All @@ -37,6 +22,10 @@ const total = 0

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
Expand All @@ -45,17 +34,21 @@ hdr-histogram-percentiles-obj has two utility functions to use

### histAsObj(histogram, total)

* `histogram`: A native-hdr-histogram object you want to get some values from in a js object
* `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, optional

Returns a json object with the `min`, `max`, `average` (mean) and `stddev`

### addPercentiles(histogram, histAsObjResult)

* `histogram`: A native-hdr-histogram object you want to retrieve the percentiles from
* `histAsObjResult`: the result returned when `histAsObj` is called on some native-hdr-histogram object
* `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 object

Returns 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

Returns the histAsObjResult with the percentiles properties added
An array listing the percentiles that hdr-histogram-percentiles-obj adds, as numbers.

## Sponsor

Expand Down

0 comments on commit 3ccbf23

Please sign in to comment.