Skip to content

Commit fc553fd

Browse files
DiegoTUIgireeshpunathil
authored andcommitted
benchmark: add clear connections to secure-pair
adds clear connections to the secure-pair performance test to prove that in some cases (when the sender send the data in small chunks) clear connections perform worse than TLS connections Also add a byte chunk size test to benchmark/net/net-pipe.js Refs: #27970 PR-URL: #27971 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent 9e6c2ba commit fc553fd

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

benchmark/net/net-pipe.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const net = require('net');
66
const PORT = common.PORT;
77

88
const bench = common.createBenchmark(main, {
9-
len: [64, 102400, 1024 * 1024 * 16],
9+
len: [2, 64, 102400, 1024 * 1024 * 16],
1010
type: ['utf', 'asc', 'buf'],
1111
dur: [5],
1212
});

benchmark/tls/secure-pair.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
const common = require('../common.js');
33
const bench = common.createBenchmark(main, {
44
dur: [5],
5-
securing: ['SecurePair', 'TLSSocket'],
6-
size: [2, 1024, 1024 * 1024]
5+
securing: ['SecurePair', 'TLSSocket', 'clear'],
6+
size: [2, 100, 1024, 1024 * 1024]
77
});
88

99
const fixtures = require('../../test/common/fixtures');
@@ -37,7 +37,8 @@ function main({ dur, size, securing }) {
3737
isServer: false,
3838
rejectUnauthorized: false,
3939
};
40-
const conn = tls.connect(clientOptions, () => {
40+
const network = securing === 'clear' ? net : tls;
41+
const conn = network.connect(clientOptions, () => {
4142
setTimeout(() => {
4243
const mbits = (received * 8) / (1024 * 1024);
4344
bench.end(mbits);
@@ -69,6 +70,9 @@ function main({ dur, size, securing }) {
6970
case 'TLSSocket':
7071
secureTLSSocket(conn, client);
7172
break;
73+
case 'clear':
74+
conn.pipe(client);
75+
break;
7276
default:
7377
throw new Error('Invalid securing method');
7478
}

0 commit comments

Comments
 (0)