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

Function client

benchmark/net/tcp-raw-s2c.js:103–135  ·  view source on GitHub ↗
(dur)

Source from the content-addressed store, hash-verified

101 }
102
103 function client(dur) {
104 const clientHandle = new TCP(TCPConstants.SOCKET);
105 const connectReq = new TCPConnectWrap();
106 const err = clientHandle.connect(connectReq, '127.0.0.1', PORT);
107
108 if (err)
109 fail(err, 'connect');
110
111 connectReq.oncomplete = function() {
112 let bytes = 0;
113 clientHandle.onread = function(buffer) {
114 // We're not expecting to ever get an EOF from the client.
115 // Just lots of data forever.
116 if (!buffer)
117 fail('read');
118
119 // Don't slice the buffer. The point of this is to isolate, not
120 // simulate real traffic.
121 bytes += buffer.byteLength;
122 };
123
124 clientHandle.readStart();
125
126 // The meat of the benchmark is right here:
127 bench.start();
128
129 setTimeout(() => {
130 // report in Gb/sec
131 bench.end((bytes * 8) / (1024 * 1024 * 1024));
132 process.exit(0);
133 }, dur * 1000);
134 };
135 }
136}

Callers 1

mainFunction · 0.70

Calls 7

failFunction · 0.70
connectMethod · 0.65
setTimeoutFunction · 0.50
readStartMethod · 0.45
startMethod · 0.45
endMethod · 0.45
exitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…