Skip to content

Commit

Permalink
benchmark: add node-error benchmark
Browse files Browse the repository at this point in the history
PR-URL: #43077
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
  • Loading branch information
RafaelGSS authored and targos committed Jul 31, 2022
1 parent f453918 commit 986fb3e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
14 changes: 14 additions & 0 deletions benchmark/error/error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

const common = require('../common.js');

const bench = common.createBenchmark(main, {
n: [1e7],
});

function main({ n }) {
bench.start();
for (let i = 0; i < n; ++i)
new Error('test');
bench.end(n);
}
21 changes: 21 additions & 0 deletions benchmark/error/node-error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

const common = require('../common');

const bench = common.createBenchmark(main, {
n: [1e7],
}, {
flags: ['--expose-internals']
});

function main({ n }) {
const {
codes: {
ERR_INVALID_STATE,
}
} = require('internal/errors');
bench.start();
for (let i = 0; i < n; ++i)
new ERR_INVALID_STATE.TypeError('test');
bench.end(n);
}

0 comments on commit 986fb3e

Please sign in to comment.