0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/benchmark/arrays/zero-int.js
Anatoli Papirovski 71cc57e472
benchmark: do not multiply n by 1e6 in arrays
PR-URL: https://github.com/nodejs/node/pull/20125
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2018-04-22 11:06:40 +02:00

36 lines
576 B
JavaScript

'use strict';
const common = require('../common.js');
const bench = common.createBenchmark(main, {
type: [
'Array',
'Buffer',
'Int8Array',
'Uint8Array',
'Int16Array',
'Uint16Array',
'Int32Array',
'Uint32Array',
'Float32Array',
'Float64Array'
],
n: [25e6]
});
function main({ type, n }) {
const clazz = global[type];
bench.start();
const arr = new clazz(n);
for (var i = 0; i < 10; ++i) {
run();
}
bench.end(n);
function run() {
for (var j = 0, k = arr.length; j < k; ++j) {
arr[j] = 0;
}
}
}