mirror of
https://github.com/nodejs/node.git
synced 2024-11-24 12:10:08 +01:00
4f84a3d200
PR-URL: https://github.com/nodejs/node/pull/49642 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: LiviaMedeiros <livia@cirno.name> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
45 lines
659 B
JavaScript
45 lines
659 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common.js');
|
|
|
|
const bench = common.createBenchmark(main, {
|
|
n: [1e7],
|
|
input: [
|
|
'',
|
|
'a',
|
|
'a,b',
|
|
'a,b,c',
|
|
'a,b,c,d',
|
|
],
|
|
type: [
|
|
'undefined',
|
|
'and',
|
|
'or',
|
|
],
|
|
}, {
|
|
flags: ['--expose-internals'],
|
|
});
|
|
|
|
function main({ n, input, type }) {
|
|
const {
|
|
formatList,
|
|
} = require('internal/errors');
|
|
|
|
const list = input.split(',');
|
|
|
|
if (type === 'undefined') {
|
|
bench.start();
|
|
for (let i = 0; i < n; ++i) {
|
|
formatList(list);
|
|
}
|
|
bench.end(n);
|
|
return;
|
|
}
|
|
|
|
bench.start();
|
|
for (let i = 0; i < n; ++i) {
|
|
formatList(list, type);
|
|
}
|
|
bench.end(n);
|
|
}
|