We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
nodejs
Learn more about funding links in repositories.
Report abuse
1 parent 8f10156 commit 6db777fCopy full SHA for 6db777f
benchmark/assert/throws.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: ['throws', 'doesNotThrow'],
9
+});
10
11
+function main({ n, method }) {
12
+ const fn = assert[method];
13
+ const shouldThrow = method === 'throws';
14
15
+ bench.start();
16
+ for (let i = 0; i < n; ++i) {
17
+ fn(() => {
18
+ const err = new Error(`assert.${method}`);
19
+ if (shouldThrow) {
20
+ throw err;
21
+ } else {
22
+ return err;
23
+ }
24
+ });
25
26
+ bench.end(n);
27
+}
0 commit comments