0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-27 22:16:50 +01:00
nodejs/benchmark/error/error-class-reg-exp.js
Uzlopak db8217b1bf
errors: improve classRegExp in errors.js
PR-URL: https://github.com/nodejs/node/pull/49643
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2023-09-16 01:36:48 +00:00

24 lines
468 B
JavaScript

'use strict';
const common = require('../common.js');
const bench = common.createBenchmark(main, {
n: [1e5],
}, {
flags: ['--expose-internals'],
});
const instances = Array.from({ length: 1000 }).map(() => 'Uint8Array');
function main({ n }) {
const {
codes: {
ERR_INVALID_ARG_TYPE,
},
} = require('internal/errors');
bench.start();
for (let i = 0; i < n; ++i)
new ERR_INVALID_ARG_TYPE('target', instances, 'test');
bench.end(n);
}