mirror of
https://github.com/nodejs/node.git
synced 2024-11-28 14:33:11 +01:00
b26238132b
PR-URL: https://github.com/nodejs/node/pull/54734 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
28 lines
551 B
JavaScript
28 lines
551 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common.js');
|
|
const assert = require('assert');
|
|
|
|
const bench = common.createBenchmark(main, {
|
|
n: [25, 2e5],
|
|
method: ['rejects', 'doesNotReject'],
|
|
});
|
|
|
|
async function main({ n, method }) {
|
|
const fn = assert[method];
|
|
const shouldReject = method === 'rejects';
|
|
|
|
bench.start();
|
|
for (let i = 0; i < n; ++i) {
|
|
await fn(async () => {
|
|
const err = new Error(`assert.${method}`);
|
|
if (shouldReject) {
|
|
throw err;
|
|
} else {
|
|
return err;
|
|
}
|
|
});
|
|
}
|
|
bench.end(n);
|
|
}
|