mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
c97322adff
PR-URL: https://github.com/nodejs/node/pull/51026 Refs: https://github.com/nodejs/performance/issues/136 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
23 lines
454 B
JavaScript
23 lines
454 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common.js');
|
|
const { createHash } = require('crypto');
|
|
const assert = require('assert');
|
|
|
|
const bench = common.createBenchmark(main, {
|
|
n: [1e5],
|
|
});
|
|
|
|
function main({ n }) {
|
|
const array = [];
|
|
for (let i = 0; i < n; ++i) {
|
|
array.push(null);
|
|
}
|
|
bench.start();
|
|
for (let i = 0; i < n; ++i) {
|
|
array[i] = createHash('sha1');
|
|
}
|
|
bench.end(n);
|
|
assert.strictEqual(typeof array[n - 1], 'object');
|
|
}
|