Updated the files.
This commit is contained in:
parent
1553e6b971
commit
753967d4f5
23418 changed files with 3784666 additions and 0 deletions
21
my-app/node_modules/hdr-histogram-percentiles-obj/LICENSE
generated
vendored
Executable file
21
my-app/node_modules/hdr-histogram-percentiles-obj/LICENSE
generated
vendored
Executable file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Glen Keane
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
83
my-app/node_modules/hdr-histogram-percentiles-obj/index.js
generated
vendored
Executable file
83
my-app/node_modules/hdr-histogram-percentiles-obj/index.js
generated
vendored
Executable file
|
@ -0,0 +1,83 @@
|
|||
'use strict'
|
||||
|
||||
const percentiles = module.exports.percentiles = [
|
||||
0.001,
|
||||
0.01,
|
||||
0.1,
|
||||
1,
|
||||
2.5,
|
||||
10,
|
||||
25,
|
||||
50,
|
||||
75,
|
||||
90,
|
||||
97.5,
|
||||
99,
|
||||
99.9,
|
||||
99.99,
|
||||
99.999
|
||||
]
|
||||
|
||||
module.exports.histAsObj = function (hist, total) {
|
||||
const mean = Math.ceil(getMean(hist) * 100) / 100
|
||||
const result = {
|
||||
average: mean, // added for backward compat with wrk
|
||||
mean: mean,
|
||||
stddev: Math.ceil(getStdDeviation(hist) * 100) / 100,
|
||||
min: getMin(hist),
|
||||
max: getMax(hist)
|
||||
}
|
||||
|
||||
if (typeof total === 'number') {
|
||||
result.total = total
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
module.exports.addPercentiles = function (hist, result) {
|
||||
percentiles.forEach(function (perc) {
|
||||
const key = ('p' + perc).replace('.', '_')
|
||||
if (typeof hist.percentile === 'function') {
|
||||
result[key] = hist.percentile(perc)
|
||||
} else if (typeof hist.getValueAtPercentile === 'function') {
|
||||
result[key] = hist.getValueAtPercentile(perc)
|
||||
}
|
||||
})
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
function getMean (hist) {
|
||||
if (typeof hist.mean === 'function') {
|
||||
return hist.mean()
|
||||
}
|
||||
if (typeof hist.getMean === 'function') {
|
||||
return hist.getMean()
|
||||
}
|
||||
return hist.mean
|
||||
}
|
||||
|
||||
function getMin (hist) {
|
||||
if (typeof hist.min === 'function') {
|
||||
return hist.min()
|
||||
}
|
||||
return hist.minNonZeroValue
|
||||
}
|
||||
|
||||
function getMax (hist) {
|
||||
if (typeof hist.max === 'function') {
|
||||
return hist.max()
|
||||
}
|
||||
return hist.maxValue
|
||||
}
|
||||
|
||||
function getStdDeviation (hist) {
|
||||
if (typeof hist.stddev === 'function') {
|
||||
return hist.stddev()
|
||||
}
|
||||
if (typeof hist.getStdDeviation === 'function') {
|
||||
return hist.getStdDeviation()
|
||||
}
|
||||
return hist.stdDeviation
|
||||
}
|
33
my-app/node_modules/hdr-histogram-percentiles-obj/package.json
generated
vendored
Executable file
33
my-app/node_modules/hdr-histogram-percentiles-obj/package.json
generated
vendored
Executable file
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"name": "hdr-histogram-percentiles-obj",
|
||||
"version": "3.0.0",
|
||||
"description": "A little lib for turning hdr-histogram-js to objects",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "standard && tap ./test/*.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/GlenTiki/hdr-histogram-percentiles-obj.git"
|
||||
},
|
||||
"keywords": [
|
||||
"hdr-histogram",
|
||||
"hdr-histogram-js",
|
||||
"percentiles"
|
||||
],
|
||||
"author": "Glen Keane <glenkeane.94@gmail.com>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/GlenTiki/hdr-histogram-percentiles-obj/issues"
|
||||
},
|
||||
"pre-commit": [
|
||||
"test"
|
||||
],
|
||||
"homepage": "https://github.com/GlenTiki/hdr-histogram-percentiles-obj#readme",
|
||||
"devDependencies": {
|
||||
"pre-commit": "^1.1.3",
|
||||
"standard": "^14.0.0",
|
||||
"tap": "^14.0.0",
|
||||
"hdr-histogram-js": "^2.0.0"
|
||||
}
|
||||
}
|
59
my-app/node_modules/hdr-histogram-percentiles-obj/readme.md
generated
vendored
Executable file
59
my-app/node_modules/hdr-histogram-percentiles-obj/readme.md
generated
vendored
Executable file
|
@ -0,0 +1,59 @@
|
|||
# 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, optional
|
||||
|
||||
Returns 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 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
|
||||
|
||||
An array listing the percentiles that hdr-histogram-percentiles-obj adds, as numbers.
|
||||
|
||||
## Sponsor
|
||||
|
||||
Kindly sponsored by [nearForm](www.nearform.com)
|
||||
|
||||
## License
|
||||
|
||||
[MIT](./LICENSE)
|
92
my-app/node_modules/hdr-histogram-percentiles-obj/test/hdr-js.js
generated
vendored
Executable file
92
my-app/node_modules/hdr-histogram-percentiles-obj/test/hdr-js.js
generated
vendored
Executable file
|
@ -0,0 +1,92 @@
|
|||
'use strict'
|
||||
|
||||
const test = require('tap').test
|
||||
const hdr = require('hdr-histogram-js')
|
||||
const histPercentileObj = require('../')
|
||||
|
||||
test('should return a valid hist as object', (t) => {
|
||||
t.plan(24)
|
||||
const histogram = hdr.build({
|
||||
lowestDiscernibleValue: 1,
|
||||
highestTrackableValue: 100
|
||||
})
|
||||
let total = 0
|
||||
for (let i = 0; i < 10000; i++) {
|
||||
const num = Math.floor(Math.random() * 100)
|
||||
histogram.recordValue(num)
|
||||
total += num
|
||||
}
|
||||
|
||||
// any of the numbers below _could_ be 0, so we do a type test instead of t.ok
|
||||
const result = histPercentileObj.histAsObj(histogram, total)
|
||||
t.ok(result)
|
||||
t.type(result.average, 'number')
|
||||
t.type(result.mean, 'number')
|
||||
t.type(result.stddev, 'number')
|
||||
t.type(result.min, 'number')
|
||||
t.type(result.max, 'number')
|
||||
t.type(result.total, 'number')
|
||||
|
||||
const withPercentiles = histPercentileObj.addPercentiles(histogram, result)
|
||||
t.ok(withPercentiles)
|
||||
t.type(withPercentiles.average, 'number')
|
||||
t.type(withPercentiles.p0_001, 'number')
|
||||
t.type(withPercentiles.p0_01, 'number')
|
||||
t.type(withPercentiles.p0_1, 'number')
|
||||
t.type(withPercentiles.p1, 'number')
|
||||
t.type(withPercentiles.p2_5, 'number')
|
||||
t.type(withPercentiles.p10, 'number')
|
||||
t.type(withPercentiles.p25, 'number')
|
||||
t.type(withPercentiles.p50, 'number')
|
||||
t.type(withPercentiles.p75, 'number')
|
||||
t.type(withPercentiles.p90, 'number')
|
||||
t.type(withPercentiles.p97_5, 'number')
|
||||
t.type(withPercentiles.p99, 'number')
|
||||
t.type(withPercentiles.p99_9, 'number')
|
||||
t.type(withPercentiles.p99_99, 'number')
|
||||
t.type(withPercentiles.p99_999, 'number')
|
||||
})
|
||||
|
||||
test('should return expected numbers', (t) => {
|
||||
t.plan(18)
|
||||
const histogram = hdr.build({
|
||||
lowestDiscernibleValue: 1,
|
||||
highestTrackableValue: 10
|
||||
})
|
||||
|
||||
histogram.recordValue(4)
|
||||
histogram.recordValue(5)
|
||||
histogram.recordValue(6)
|
||||
|
||||
// any of the numbers below _could_ be 0, so we do a type test instead of t.ok
|
||||
const result = histPercentileObj.histAsObj(histogram, 15)
|
||||
t.ok(result)
|
||||
t.equal(result.average, 5)
|
||||
t.equal(result.mean, 5)
|
||||
t.equal(result.stddev, 0.82)
|
||||
t.equal(result.min, 4)
|
||||
t.equal(result.max, 6)
|
||||
t.equal(result.total, 15)
|
||||
|
||||
const withPercentiles = histPercentileObj.addPercentiles(histogram, result)
|
||||
t.ok(withPercentiles)
|
||||
t.equal(withPercentiles.average, 5)
|
||||
t.equal(withPercentiles.p2_5, 4)
|
||||
t.equal(withPercentiles.p50, 5)
|
||||
t.equal(withPercentiles.p75, 6)
|
||||
t.equal(withPercentiles.p90, 6)
|
||||
t.equal(withPercentiles.p97_5, 6)
|
||||
t.equal(withPercentiles.p99, 6)
|
||||
t.equal(withPercentiles.p99_9, 6)
|
||||
t.equal(withPercentiles.p99_99, 6)
|
||||
t.equal(withPercentiles.p99_999, 6)
|
||||
})
|
||||
|
||||
test('should return a valid hist as object from a WASM histogram', (t) => {
|
||||
t.plan(1)
|
||||
hdr.initWebAssemblySync()
|
||||
const histogram = hdr.build({
|
||||
useWebAssembly: true
|
||||
})
|
||||
t.ok(histPercentileObj.histAsObj(histogram))
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue