hdr-histogram-percentiles-obj
Advanced tools
Comparing version 1.1.0 to 1.2.0
45
index.js
@@ -14,9 +14,9 @@ 'use strict' | ||
module.exports.histAsObj = function (hist, total) { | ||
const mean = Math.ceil(hist.mean() * 100) / 100 | ||
const mean = Math.ceil(getMean(hist) * 100) / 100 | ||
const result = { | ||
average: mean, // added for backward compat with wrk | ||
mean: mean, | ||
stddev: Math.ceil(hist.stddev() * 100) / 100, | ||
min: hist.min(), | ||
max: hist.max() | ||
stddev: Math.ceil(getStdDeviation(hist) * 100) / 100, | ||
min: getMin(hist), | ||
max: getMax(hist) | ||
} | ||
@@ -34,3 +34,7 @@ | ||
const key = ('p' + perc).replace('.', '') | ||
result[key] = hist.percentile(perc) | ||
if (typeof hist.percentile === 'function') { | ||
result[key] = hist.percentile(perc) | ||
} else if (typeof hist.getValueAtPercentile === 'function') { | ||
result[key] = hist.getValueAtPercentile(perc) | ||
} | ||
}) | ||
@@ -40,1 +44,32 @@ | ||
} | ||
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() | ||
} | ||
return hist.getStdDeviation() | ||
} |
{ | ||
"name": "hdr-histogram-percentiles-obj", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "A little lib for turning native-hdr-histograms to objects", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "standard && tap ./test.js" | ||
"test": "standard && tap ./test/*.js" | ||
}, | ||
@@ -26,7 +26,10 @@ "repository": { | ||
"devDependencies": { | ||
"native-hdr-histogram": "^0.3.2", | ||
"standard": "^7.1.2", | ||
"native-hdr-histogram": "^0.4.6", | ||
"standard": "^10.0.3", | ||
"pre-commit": "^1.1.3", | ||
"tap": "^6.1.1" | ||
"tap": "^11.0.1" | ||
}, | ||
"dependencies": { | ||
"hdr-histogram-js": "^1.0.0" | ||
} | ||
} |
@@ -9,3 +9,3 @@ # hdr-histogram-percentiles-obj | ||
## Usage | ||
## Usage with native-hdr-histogram | ||
@@ -25,2 +25,20 @@ ```js | ||
## Usage with hdr-histogram-js | ||
```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)) | ||
``` | ||
## API | ||
@@ -27,0 +45,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11522
7
245
67
1
+ Addedhdr-histogram-js@^1.0.0
+ Addedbase64-js@1.5.1(transitive)
+ Addedhdr-histogram-js@1.2.0(transitive)
+ Addedpako@1.0.11(transitive)