Skip to content

v1.3.0

Choose a tag to compare

@d4rkr00t d4rkr00t released this 24 Apr 07:28
· 16 commits to master since this release

Features

Support an array of percentiles (179a027), closes #101

Add support for calcualting and array of percentiles in 1 pass, example:

const percentile = require("percentile");
const result = percentile(
  [70, 80, 90], // calculates 70p, 80p and 90p in one pass
  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
);
console.log(result); // [7, 8, 9]

It adds a little bit of overhead because, now percentile needs to convert a percentile argument to an array and apply validation and calculation to this array of percentiles, but overall performance is still in a ball park of original implementation:

Small Array – 10 items [old] x 3,024,685 ops/sec ±0.65% (94 runs sampled)
Small Array – 10 items [new] x 2,941,058 ops/sec ±1.04% (95 runs sampled)
Fastest is Small Array – 10 items [old]

Big array 10k values [old] x 5,482 ops/sec ±0.58% (92 runs sampled)
Big array 10k values [new] x 5,381 ops/sec ±0.69% (91 runs sampled)
Fastest is Big array 10k values [old]

Big array 100k values [old] x 395 ops/sec ±1.00% (91 runs sampled)
Big array 100k values [new] x 406 ops/sec ±0.93% (88 runs sampled)
Fastest is Big array 100k values [new]