Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c721d68

Browse filesBrowse files
thisalihassanaduh95
authored andcommitted
benchmark: fix destructuring in dgram/single-buffer
PR #59872 renamed the config key from `num` to `n` but did not update the destructuring in main(), leaving `{ num: n }` which resolves to undefined. This caused the benchmark to produce near-zero throughput since the send-batching logic never fires when n is undefined. Refs: #59872 PR-URL: #62084 Refs: nodejs/performance#187 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 409b066 commit c721d68
Copy full SHA for c721d68

4 files changed

+26-26Lines changed: 26 additions & 26 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎benchmark/crypto/hash-stream-creation.js‎

Copy file name to clipboardExpand all lines: benchmark/crypto/hash-stream-creation.js
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ const common = require('../common.js');
55
const crypto = require('crypto');
66

77
const bench = common.createBenchmark(main, {
8-
writes: [500],
8+
n: [500],
99
algo: [ 'sha256', 'md5' ],
1010
type: ['asc', 'utf', 'buf'],
1111
out: ['hex', 'binary', 'buffer'],
1212
len: [2, 1024, 102400, 1024 * 1024],
1313
api: ['legacy', 'stream'],
1414
});
1515

16-
function main({ api, type, len, out, writes, algo }) {
16+
function main({ api, type, len, out, n, algo }) {
1717
if (api === 'stream' && /^v0\.[0-8]\./.test(process.version)) {
1818
console.error('Crypto streams not available until v0.10');
1919
// Use the legacy, just so that we can compare them.
@@ -41,15 +41,15 @@ function main({ api, type, len, out, writes, algo }) {
4141
const fn = api === 'stream' ? streamWrite : legacyWrite;
4242

4343
bench.start();
44-
fn(algo, message, encoding, writes, len, out);
44+
fn(algo, message, encoding, n, len, out);
4545
}
4646

47-
function legacyWrite(algo, message, encoding, writes, len, outEnc) {
48-
const written = writes * len;
47+
function legacyWrite(algo, message, encoding, n, len, outEnc) {
48+
const written = n * len;
4949
const bits = written * 8;
5050
const gbits = bits / (1024 * 1024 * 1024);
5151

52-
while (writes-- > 0) {
52+
while (n-- > 0) {
5353
const h = crypto.createHash(algo);
5454
h.update(message, encoding);
5555
h.digest(outEnc);
@@ -58,12 +58,12 @@ function legacyWrite(algo, message, encoding, writes, len, outEnc) {
5858
bench.end(gbits);
5959
}
6060

61-
function streamWrite(algo, message, encoding, writes, len, outEnc) {
62-
const written = writes * len;
61+
function streamWrite(algo, message, encoding, n, len, outEnc) {
62+
const written = n * len;
6363
const bits = written * 8;
6464
const gbits = bits / (1024 * 1024 * 1024);
6565

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

6969
if (outEnc !== 'buffer')
Collapse file

‎benchmark/crypto/hash-stream-throughput.js‎

Copy file name to clipboardExpand all lines: benchmark/crypto/hash-stream-throughput.js
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ const common = require('../common.js');
55
const crypto = require('crypto');
66

77
const bench = common.createBenchmark(main, {
8-
writes: [500],
8+
n: [500],
99
algo: ['sha1', 'sha256', 'sha512'],
1010
type: ['asc', 'utf', 'buf'],
1111
len: [2, 1024, 102400, 1024 * 1024],
1212
api: ['legacy', 'stream'],
1313
});
1414

15-
function main({ api, type, len, algo, writes }) {
15+
function main({ api, type, len, algo, n }) {
1616
if (api === 'stream' && /^v0\.[0-8]\./.test(process.version)) {
1717
console.error('Crypto streams not available until v0.10');
1818
// Use the legacy, just so that we can compare them.
@@ -40,30 +40,30 @@ function main({ api, type, len, algo, writes }) {
4040
const fn = api === 'stream' ? streamWrite : legacyWrite;
4141

4242
bench.start();
43-
fn(algo, message, encoding, writes, len);
43+
fn(algo, message, encoding, n, len);
4444
}
4545

46-
function legacyWrite(algo, message, encoding, writes, len) {
47-
const written = writes * len;
46+
function legacyWrite(algo, message, encoding, n, len) {
47+
const written = n * len;
4848
const bits = written * 8;
4949
const gbits = bits / (1024 * 1024 * 1024);
5050
const h = crypto.createHash(algo);
5151

52-
while (writes-- > 0)
52+
while (n-- > 0)
5353
h.update(message, encoding);
5454

5555
h.digest();
5656

5757
bench.end(gbits);
5858
}
5959

60-
function streamWrite(algo, message, encoding, writes, len) {
61-
const written = writes * len;
60+
function streamWrite(algo, message, encoding, n, len) {
61+
const written = n * len;
6262
const bits = written * 8;
6363
const gbits = bits / (1024 * 1024 * 1024);
6464
const h = crypto.createHash(algo);
6565

66-
while (writes-- > 0)
66+
while (n-- > 0)
6767
h.write(message, encoding);
6868

6969
h.end();
Collapse file

‎benchmark/crypto/rsa-sign-verify-throughput.js‎

Copy file name to clipboardExpand all lines: benchmark/crypto/rsa-sign-verify-throughput.js
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,28 @@ keylen_list.forEach((key) => {
1717
});
1818

1919
const bench = common.createBenchmark(main, {
20-
writes: [500],
20+
n: [500],
2121
algo: ['SHA1', 'SHA224', 'SHA256', 'SHA384', 'SHA512'],
2222
keylen: keylen_list,
2323
len: [1024, 102400, 2 * 102400, 3 * 102400, 1024 * 1024],
2424
});
2525

26-
function main({ len, algo, keylen, writes }) {
26+
function main({ len, algo, keylen, n }) {
2727
const message = Buffer.alloc(len, 'b');
2828
bench.start();
29-
StreamWrite(algo, keylen, message, writes, len);
29+
StreamWrite(algo, keylen, message, n, len);
3030
}
3131

32-
function StreamWrite(algo, keylen, message, writes, len) {
33-
const written = writes * len;
32+
function StreamWrite(algo, keylen, message, n, len) {
33+
const written = n * len;
3434
const bits = written * 8;
3535
const kbits = bits / (1024);
3636

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

41-
while (writes-- > 0) {
41+
while (n-- > 0) {
4242
s.update(message);
4343
v.update(message);
4444
}
Collapse file

‎benchmark/dgram/single-buffer.js‎

Copy file name to clipboardExpand all lines: benchmark/dgram/single-buffer.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const common = require('../common.js');
55
const dgram = require('dgram');
66
const PORT = common.PORT;
77

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

18-
function main({ dur, len, num: n, type }) {
18+
function main({ dur, len, n, type }) {
1919
const chunk = Buffer.allocUnsafe(len);
2020
let sent = 0;
2121
let received = 0;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.