hdr-histogram-percentiles-obj
Advanced tools
Comparing version 1.0.0 to 1.0.3
@@ -0,1 +1,3 @@ | ||
'use strict' | ||
const percentiles = [ | ||
@@ -2,0 +4,0 @@ 50, |
{ | ||
"name": "hdr-histogram-percentiles-obj", | ||
"version": "1.0.0", | ||
"version": "1.0.3", | ||
"description": "A little lib for turning native-hdr-histograms to objects", | ||
@@ -21,2 +21,5 @@ "main": "index.js", | ||
}, | ||
"pre-commit": [ | ||
"test" | ||
], | ||
"homepage": "https://github.com/thekemkid/hdr-histogram-percentiles-obj#readme", | ||
@@ -26,4 +29,5 @@ "devDependencies": { | ||
"standard": "^7.1.2", | ||
"pre-commit": "^1.1.3", | ||
"tap": "^6.1.1" | ||
} | ||
} |
32
test.js
@@ -0,1 +1,3 @@ | ||
'use strict' | ||
const test = require('tap').test | ||
@@ -36,1 +38,31 @@ const Histogram = require('native-hdr-histogram') | ||
}) | ||
test('should return expected numbers', (t) => { | ||
t.plan(16) | ||
const histogram = new Histogram(1, 10) | ||
histogram.record(4) | ||
histogram.record(5) | ||
histogram.record(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.p50, 5) | ||
t.equal(withPercentiles.p75, 5) | ||
t.equal(withPercentiles.p90, 6) | ||
t.equal(withPercentiles.p99, 6) | ||
t.equal(withPercentiles.p999, 6) | ||
t.equal(withPercentiles.p9999, 6) | ||
t.equal(withPercentiles.p99999, 6) | ||
}) |
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
5917
90
4