Skip to content

Commit

Permalink
benchmark: add node-error benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelGSS committed May 25, 2022
1 parent 8b415e8 commit 64fc8c1
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 64fc8c1

Please sign in to comment.