-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
benchmark: add create-hash benchmark
PR-URL: #51026 Refs: nodejs/performance#136 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
- Loading branch information
1 parent
c45a9a3
commit b148c43
Showing
2 changed files
with
23 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'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'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters