test: run crypto benchmark only once in tests
Prevent crypto benchmark files from running more than one benchmark during tests. PR-URL: https://github.com/nodejs/node/pull/21032 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
This commit is contained in:
parent
862a22ab49
commit
6168959546
@ -9,6 +9,9 @@ const bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main({ n, len, cipher }) {
|
function main({ n, len, cipher }) {
|
||||||
|
// Default cipher for tests.
|
||||||
|
if (cipher === '')
|
||||||
|
cipher = 'aes-128-gcm';
|
||||||
const message = Buffer.alloc(len, 'b');
|
const message = Buffer.alloc(len, 'b');
|
||||||
const key = crypto.randomBytes(keylen[cipher]);
|
const key = crypto.randomBytes(keylen[cipher]);
|
||||||
const iv = crypto.randomBytes(12);
|
const iv = crypto.randomBytes(12);
|
||||||
|
@ -10,6 +10,9 @@ const bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main({ api, cipher, type, len, writes }) {
|
function main({ api, cipher, type, len, writes }) {
|
||||||
|
// Default cipher for tests.
|
||||||
|
if (cipher === '')
|
||||||
|
cipher = 'AES192';
|
||||||
if (api === 'stream' && /^v0\.[0-8]\./.test(process.version)) {
|
if (api === 'stream' && /^v0\.[0-8]\./.test(process.version)) {
|
||||||
console.error('Crypto streams not available until v0.10');
|
console.error('Crypto streams not available until v0.10');
|
||||||
// use the legacy, just so that we can compare them.
|
// use the legacy, just so that we can compare them.
|
||||||
|
@ -12,14 +12,15 @@ const runBenchmark = require('../common/benchmark');
|
|||||||
|
|
||||||
runBenchmark('crypto',
|
runBenchmark('crypto',
|
||||||
[
|
[
|
||||||
'n=1',
|
|
||||||
'algo=sha256',
|
'algo=sha256',
|
||||||
'api=stream',
|
'api=stream',
|
||||||
|
'cipher=',
|
||||||
'keylen=1024',
|
'keylen=1024',
|
||||||
'len=1',
|
'len=1',
|
||||||
|
'n=1',
|
||||||
'out=buffer',
|
'out=buffer',
|
||||||
'type=buf',
|
'type=buf',
|
||||||
'v=crypto',
|
'v=crypto',
|
||||||
'writes=1'
|
'writes=1',
|
||||||
],
|
],
|
||||||
{ NODEJS_BENCHMARK_ZERO_ALLOWED: 1 });
|
{ NODEJS_BENCHMARK_ZERO_ALLOWED: 1 });
|
||||||
|
Loading…
x
Reference in New Issue
Block a user