Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions benchmark/crypto/hash-stream-creation.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ const common = require('../common.js');
const crypto = require('crypto');

const bench = common.createBenchmark(main, {
writes: [500],
n: [500],
algo: [ 'sha256', 'md5' ],
type: ['asc', 'utf', 'buf'],
out: ['hex', 'binary', 'buffer'],
len: [2, 1024, 102400, 1024 * 1024],
api: ['legacy', 'stream'],
});

function main({ api, type, len, out, writes, algo }) {
function main({ api, type, len, out, n, algo }) {
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 Expand Up @@ -41,15 +41,15 @@ function main({ api, type, len, out, writes, algo }) {
const fn = api === 'stream' ? streamWrite : legacyWrite;

bench.start();
fn(algo, message, encoding, writes, len, out);
fn(algo, message, encoding, n, len, out);
}

function legacyWrite(algo, message, encoding, writes, len, outEnc) {
const written = writes * len;
function legacyWrite(algo, message, encoding, n, len, outEnc) {
const written = n * len;
const bits = written * 8;
const gbits = bits / (1024 * 1024 * 1024);

while (writes-- > 0) {
while (n-- > 0) {
const h = crypto.createHash(algo);
h.update(message, encoding);
h.digest(outEnc);
Expand All @@ -58,12 +58,12 @@ function legacyWrite(algo, message, encoding, writes, len, outEnc) {
bench.end(gbits);
}

function streamWrite(algo, message, encoding, writes, len, outEnc) {
const written = writes * len;
function streamWrite(algo, message, encoding, n, len, outEnc) {
const written = n * len;
const bits = written * 8;
const gbits = bits / (1024 * 1024 * 1024);

while (writes-- > 0) {
while (n-- > 0) {
const h = crypto.createHash(algo);

if (outEnc !== 'buffer')
Expand Down
18 changes: 9 additions & 9 deletions benchmark/crypto/hash-stream-throughput.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ const common = require('../common.js');
const crypto = require('crypto');

const bench = common.createBenchmark(main, {
writes: [500],
n: [500],
algo: ['sha1', 'sha256', 'sha512'],
type: ['asc', 'utf', 'buf'],
len: [2, 1024, 102400, 1024 * 1024],
api: ['legacy', 'stream'],
});

function main({ api, type, len, algo, writes }) {
function main({ api, type, len, algo, n }) {
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 Expand Up @@ -40,30 +40,30 @@ function main({ api, type, len, algo, writes }) {
const fn = api === 'stream' ? streamWrite : legacyWrite;

bench.start();
fn(algo, message, encoding, writes, len);
fn(algo, message, encoding, n, len);
}

function legacyWrite(algo, message, encoding, writes, len) {
const written = writes * len;
function legacyWrite(algo, message, encoding, n, len) {
const written = n * len;
const bits = written * 8;
const gbits = bits / (1024 * 1024 * 1024);
const h = crypto.createHash(algo);

while (writes-- > 0)
while (n-- > 0)
h.update(message, encoding);

h.digest();

bench.end(gbits);
}

function streamWrite(algo, message, encoding, writes, len) {
const written = writes * len;
function streamWrite(algo, message, encoding, n, len) {
const written = n * len;
const bits = written * 8;
const gbits = bits / (1024 * 1024 * 1024);
const h = crypto.createHash(algo);

while (writes-- > 0)
while (n-- > 0)
h.write(message, encoding);

h.end();
Expand Down
12 changes: 6 additions & 6 deletions benchmark/crypto/rsa-sign-verify-throughput.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,28 @@ keylen_list.forEach((key) => {
});

const bench = common.createBenchmark(main, {
writes: [500],
n: [500],
algo: ['SHA1', 'SHA224', 'SHA256', 'SHA384', 'SHA512'],
keylen: keylen_list,
len: [1024, 102400, 2 * 102400, 3 * 102400, 1024 * 1024],
});

function main({ len, algo, keylen, writes }) {
function main({ len, algo, keylen, n }) {
const message = Buffer.alloc(len, 'b');
bench.start();
StreamWrite(algo, keylen, message, writes, len);
StreamWrite(algo, keylen, message, n, len);
}

function StreamWrite(algo, keylen, message, writes, len) {
const written = writes * len;
function StreamWrite(algo, keylen, message, n, len) {
const written = n * len;
const bits = written * 8;
const kbits = bits / (1024);

const privateKey = RSA_PrivatePem[keylen];
const s = crypto.createSign(algo);
const v = crypto.createVerify(algo);

while (writes-- > 0) {
while (n-- > 0) {
s.update(message);
v.update(message);
}
Expand Down
4 changes: 2 additions & 2 deletions benchmark/dgram/single-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const common = require('../common.js');
const dgram = require('dgram');
const PORT = common.PORT;

// `num` is the number of send requests to queue up each time.
// `n` is the number of send requests to queue up each time.
// Keep it reasonably high (>10) otherwise you're benchmarking the speed of
// event loop cycles more than anything else.
const bench = common.createBenchmark(main, {
Expand All @@ -15,7 +15,7 @@ const bench = common.createBenchmark(main, {
dur: [5],
});

function main({ dur, len, num: n, type }) {
function main({ dur, len, n, type }) {
const chunk = Buffer.allocUnsafe(len);
let sent = 0;
let received = 0;
Expand Down
Loading