Skip to content

Commit 509bf09

Browse files
committed
benchmark: added clear connections to secure-pair performance test
adds clear connections to the secure-pair performance test to prove thah in some cases (when the sender send the data in small chunks) clear connections perform worse than TLS connections Refs: nodejs#27970
1 parent ff4a71c commit 509bf09

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

benchmark/tls/secure-pair.js

Lines changed: 7 additions & 3 deletions
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 fs = require('fs');
@@ -39,7 +39,8 @@ function main({ dur, size, securing }) {
3939
isServer: false,
4040
rejectUnauthorized: false,
4141
};
42-
const conn = tls.connect(clientOptions, () => {
42+
const network = securing === 'clear' ? net : tls;
43+
const conn = network.connect(clientOptions, () => {
4344
setTimeout(() => {
4445
const mbits = (received * 8) / (1024 * 1024);
4546
bench.end(mbits);
@@ -71,6 +72,9 @@ function main({ dur, size, securing }) {
7172
case 'TLSSocket':
7273
secureTLSSocket(conn, client);
7374
break;
75+
case 'clear':
76+
conn.pipe(client);
77+
break;
7478
default:
7579
throw new Error('Invalid securing method');
7680
}

0 commit comments

Comments
 (0)