Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hdr-histogram-percentiles-obj

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hdr-histogram-percentiles-obj - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

test/hdr-js.js

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()
}

13

package.json
{
"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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc