Skip to content

Commit

Permalink
benchmark: add clear connections to secure-pair
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
  • Loading branch information
DiegoTUI authored and BethGriggs committed Feb 6, 2020
1 parent fa677ca commit aa973c5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion benchmark/net/net-pipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const net = require('net');
const PORT = common.PORT;

const bench = common.createBenchmark(main, {
len: [64, 102400, 1024 * 1024 * 16],
len: [2, 64, 102400, 1024 * 1024 * 16],
type: ['utf', 'asc', 'buf'],
dur: [5],
});
Expand Down
10 changes: 7 additions & 3 deletions benchmark/tls/secure-pair.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
const common = require('../common.js');
const bench = common.createBenchmark(main, {
dur: [5],
securing: ['SecurePair', 'TLSSocket'],
size: [2, 1024, 1024 * 1024]
securing: ['SecurePair', 'TLSSocket', 'clear'],
size: [2, 100, 1024, 1024 * 1024]
});

const fixtures = require('../../test/common/fixtures');
Expand Down Expand Up @@ -37,7 +37,8 @@ function main({ dur, size, securing }) {
isServer: false,
rejectUnauthorized: false,
};
const conn = tls.connect(clientOptions, () => {
const network = securing === 'clear' ? net : tls;
const conn = network.connect(clientOptions, () => {
setTimeout(() => {
const mbits = (received * 8) / (1024 * 1024);
bench.end(mbits);
Expand Down Expand Up @@ -69,6 +70,9 @@ function main({ dur, size, securing }) {
case 'TLSSocket':
secureTLSSocket(conn, client);
break;
case 'clear':
conn.pipe(client);
break;
default:
throw new Error('Invalid securing method');
}
Expand Down

0 comments on commit aa973c5

Please sign in to comment.