Skip to content

Commit c8ee379

Browse files
TrottMylesBorins
authored andcommitted
test: run crypto benchmark only once in tests
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]>
1 parent a3fdd2e commit c8ee379

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

benchmark/crypto/aes-gcm-throughput.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ const bench = common.createBenchmark(main, {
99
});
1010

1111
function main({ n, len, cipher }) {
12+
// Default cipher for tests.
13+
if (cipher === '')
14+
cipher = 'aes-128-gcm';
1215
const message = Buffer.alloc(len, 'b');
1316
const key = crypto.randomBytes(keylen[cipher]);
1417
const iv = crypto.randomBytes(12);

benchmark/crypto/cipher-stream.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ const bench = common.createBenchmark(main, {
1010
});
1111

1212
function main({ api, cipher, type, len, writes }) {
13+
// Default cipher for tests.
14+
if (cipher === '')
15+
cipher = 'AES192';
1316
if (api === 'stream' && /^v0\.[0-8]\./.test(process.version)) {
1417
console.error('Crypto streams not available until v0.10');
1518
// use the legacy, just so that we can compare them.

test/parallel/test-benchmark-crypto.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ const runBenchmark = require('../common/benchmark');
1212

1313
runBenchmark('crypto',
1414
[
15-
'n=1',
1615
'algo=sha256',
1716
'api=stream',
17+
'cipher=',
1818
'keylen=1024',
1919
'len=1',
20+
'n=1',
2021
'out=buffer',
2122
'type=buf',
2223
'v=crypto',
23-
'writes=1'
24+
'writes=1',
2425
],
2526
{ NODEJS_BENCHMARK_ZERO_ALLOWED: 1 });

0 commit comments

Comments
 (0)