mirror of
https://github.com/nodejs/node.git
synced 2024-11-22 07:37:56 +01:00
f8c27e6176
Increase the number of iterations from 1e5 to 5e6 to avoid the test performance gap caused by inactive V8 optimization caused by insufficient number of iterations Refs: https://github.com/nodejs/node/issues/50571 PR-URL: https://github.com/nodejs/node/pull/50698 Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
34 lines
651 B
JavaScript
34 lines
651 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
const bench = common.createBenchmark(main, {
|
|
n: [5e6],
|
|
pos: ['start', 'middle', 'end'],
|
|
size: [10, 100, 500],
|
|
}, { flags: ['--expose-internals'] });
|
|
|
|
function main({ n, pos, size }) {
|
|
const { spliceOne } = require('internal/util');
|
|
const arr = new Array(size);
|
|
arr.fill('');
|
|
let index;
|
|
switch (pos) {
|
|
case 'end':
|
|
index = size - 1;
|
|
break;
|
|
case 'middle':
|
|
index = Math.floor(size / 2);
|
|
break;
|
|
default: // start
|
|
index = 0;
|
|
}
|
|
|
|
bench.start();
|
|
for (let i = 0; i < n; i++) {
|
|
spliceOne(arr, index);
|
|
arr.push('');
|
|
}
|
|
bench.end(n);
|
|
}
|