Skip to content

Commit

Permalink
benchmark: update iteration and size in benchmark/crypto/randomBytes.js
Browse files Browse the repository at this point in the history
Fixes: #50571
PR-URL: #50868
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
lucshi authored and richardlau committed Mar 25, 2024
1 parent 8ee30ea commit 278c990
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions benchmark/crypto/randomBytes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,21 @@
const common = require('../common.js');
const { randomBytes } = require('crypto');

// Add together with imports
const assert = require('assert');

let _cryptoResult;

const bench = common.createBenchmark(main, {
size: [64, 1024, 8192, 512 * 1024],
n: [1e3],
size: [64, 1024, 8 * 1024, 16 * 1024],
n: [1e5],
});

function main({ n, size }) {
bench.start();
for (let i = 0; i < n; ++i)
randomBytes(size);
_cryptoResult = randomBytes(size);
bench.end(n);
// Avoid V8 deadcode (elimination)
assert.ok(_cryptoResult);
}

0 comments on commit 278c990

Please sign in to comment.