MCPcopy Index your code
hub / github.com/nodejs/node / main

Function main

benchmark/tls/throughput-s2c.js:17–105  ·  view source on GitHub ↗
({ dur, type, sendchunklen, recvbuflen, recvbufgenfn })

Source from the content-addressed store, hash-verified

15const tls = require('tls');
16
17function main({ dur, type, sendchunklen, recvbuflen, recvbufgenfn }) {
18 if (isFinite(recvbuflen) && recvbuflen > 0)
19 recvbuf = Buffer.alloc(recvbuflen);
20
21 let encoding;
22 let chunk;
23 switch (type) {
24 case 'buf':
25 chunk = Buffer.alloc(sendchunklen, 'b');
26 break;
27 case 'asc':
28 chunk = 'a'.repeat(sendchunklen);
29 encoding = 'ascii';
30 break;
31 case 'utf':
32 chunk = 'ü'.repeat(sendchunklen / 2);
33 encoding = 'utf8';
34 break;
35 default:
36 throw new Error('invalid type');
37 }
38
39 options = {
40 key: fixtures.readKey('rsa_private.pem'),
41 cert: fixtures.readKey('rsa_cert.crt'),
42 ca: fixtures.readKey('rsa_ca.crt'),
43 ciphers: 'AES256-GCM-SHA384',
44 maxVersion: 'TLSv1.2',
45 };
46
47 let socketOpts;
48 if (recvbuf === undefined) {
49 socketOpts = { port: common.PORT, rejectUnauthorized: false };
50 } else {
51 let buffer = recvbuf;
52 if (recvbufgenfn === 'true') {
53 let bufidx = -1;
54 const bufpool = [
55 recvbuf,
56 Buffer.from(recvbuf),
57 Buffer.from(recvbuf),
58 ];
59 buffer = () => {
60 bufidx = (bufidx + 1) % bufpool.length;
61 return bufpool[bufidx];
62 };
63 }
64 socketOpts = {
65 port: common.PORT,
66 rejectUnauthorized: false,
67 onread: {
68 buffer,
69 callback: function(nread, buf) {
70 received += nread;
71 },
72 },
73 };
74 }

Callers

nothing calls this directly

Calls 9

allocMethod · 0.80
listenMethod · 0.80
writeFunction · 0.70
connectMethod · 0.65
setTimeoutFunction · 0.50
fromMethod · 0.45
onMethod · 0.45
startMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…