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 <matteo.collina@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
  • Loading branch information
RafaelGSS authored and bengl committed May 30, 2022
1 parent 0afdc3e commit aefc9dd
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 aefc9dd

Please # to comment.