benchmark: add node-error benchmark
PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
d72dcb0db4
commit
0903515e12
14
benchmark/error/error.js
Normal file
14
benchmark/error/error.js
Normal file
@ -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
benchmark/error/node-error.js
Normal file
21
benchmark/error/node-error.js
Normal file
@ -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);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user