Skip to content

Commit

Permalink
test: run crypto benchmark only once in tests
Browse files Browse the repository at this point in the history
Prevent crypto benchmark files from running more than one benchmark
during tests.

PR-URL: #21032
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anatoli Papirovski <[email protected]>
  • Loading branch information
Trott authored and MylesBorins committed Jun 6, 2018
1 parent a3fdd2e commit c8ee379
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions benchmark/crypto/aes-gcm-throughput.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const bench = common.createBenchmark(main, {
});

function main({ n, len, cipher }) {
// Default cipher for tests.
if (cipher === '')
cipher = 'aes-128-gcm';
const message = Buffer.alloc(len, 'b');
const key = crypto.randomBytes(keylen[cipher]);
const iv = crypto.randomBytes(12);
Expand Down
3 changes: 3 additions & 0 deletions benchmark/crypto/cipher-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ const bench = common.createBenchmark(main, {
});

function main({ api, cipher, type, len, writes }) {
// Default cipher for tests.
if (cipher === '')
cipher = 'AES192';
if (api === 'stream' && /^v0\.[0-8]\./.test(process.version)) {
console.error('Crypto streams not available until v0.10');
// use the legacy, just so that we can compare them.
Expand Down
5 changes: 3 additions & 2 deletions test/parallel/test-benchmark-crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ const runBenchmark = require('../common/benchmark');

runBenchmark('crypto',
[
'n=1',
'algo=sha256',
'api=stream',
'cipher=',
'keylen=1024',
'len=1',
'n=1',
'out=buffer',
'type=buf',
'v=crypto',
'writes=1'
'writes=1',
],
{ NODEJS_BENCHMARK_ZERO_ALLOWED: 1 });

0 comments on commit c8ee379

Please sign in to comment.