We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6db777f commit 66acab9Copy full SHA for 66acab9
benchmark/assert/rejects.js
@@ -0,0 +1,27 @@
1
+'use strict';
2
+
3
+const common = require('../common.js');
4
+const assert = require('assert');
5
6
+const bench = common.createBenchmark(main, {
7
+ n: [25, 2e5],
8
+ method: ['rejects', 'doesNotReject'],
9
+});
10
11
+async function main({ n, method }) {
12
+ const fn = assert[method];
13
+ const shouldReject = method === 'rejects';
14
15
+ bench.start();
16
+ for (let i = 0; i < n; ++i) {
17
+ await fn(async () => {
18
+ const err = new Error(`assert.${method}`);
19
+ if (shouldReject) {
20
+ throw err;
21
+ } else {
22
+ return err;
23
+ }
24
+ });
25
26
+ bench.end(n);
27
+}
0 commit comments