Skip to content

Commit

Permalink
fix: fixed node v14 test since histogram.count was added in v16.14+
Browse files Browse the repository at this point in the history
  • Loading branch information
titanism committed Jun 13, 2022
1 parent b1f15f2 commit 2802472
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"read-dir-deep": "^7.0.1",
"remark-cli": "^10.0.1",
"remark-preset-github": "^4.0.4",
"semver": "^7.3.7",
"xo": "^0.50.0"
},
"engines": {
Expand Down
11 changes: 9 additions & 2 deletions test/perf.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const process = require('process');
const {
monitorEventLoopDelay,
performance,
Expand All @@ -6,6 +7,7 @@ const {
} = require('perf_hooks');

const test = require('ava');
const semver = require('semver');
const { default: PQueue } = require('p-queue');

const SpamScanner = require('../');
Expand Down Expand Up @@ -186,12 +188,17 @@ test(`scan() should have no more than a 250 ms mean delay within 2 SD of mean`,
25: h.percentile(25) / 1000000,
50: h.percentile(50) / 1000000,
75: h.percentile(75) / 1000000,
// histogram.count was added in Node v16.14
// <https://nodejs.org/docs/latest-v16.x/api/perf_hooks.html#histogramcount>
count: h.count
};

t.log(h);
t.log(results.overallDelayTime);
t.true(h.count > 0);

// histogram.count was added in Node v16.14
// <https://nodejs.org/docs/latest-v16.x/api/perf_hooks.html#histogramcount>
if (semver.gte(process.version, '16.14.0')) t.true(h.count > 0);

const result =
results.overallDelayTime.mean + 2 * results.overallDelayTime.stddev;
t.log('result', result);
Expand Down

0 comments on commit 2802472

Please sign in to comment.