diff options
Diffstat (limited to 'deps/node/benchmark/http')
-rw-r--r-- | deps/node/benchmark/http/_chunky_http_client.js | 95 | ||||
-rw-r--r-- | deps/node/benchmark/http/bench-parser.js | 53 | ||||
-rw-r--r-- | deps/node/benchmark/http/check_invalid_header_char.js | 68 | ||||
-rw-r--r-- | deps/node/benchmark/http/check_is_http_token.js | 49 | ||||
-rw-r--r-- | deps/node/benchmark/http/chunked.js | 41 | ||||
-rw-r--r-- | deps/node/benchmark/http/client-request-body.js | 67 | ||||
-rw-r--r-- | deps/node/benchmark/http/cluster.js | 41 | ||||
-rw-r--r-- | deps/node/benchmark/http/create-clientrequest.js | 59 | ||||
-rw-r--r-- | deps/node/benchmark/http/end-vs-write-end.js | 57 | ||||
-rw-r--r-- | deps/node/benchmark/http/headers.js | 35 | ||||
-rw-r--r-- | deps/node/benchmark/http/http_server_for_chunky_client.js | 37 | ||||
-rw-r--r-- | deps/node/benchmark/http/incoming_headers.js | 35 | ||||
-rw-r--r-- | deps/node/benchmark/http/set-header.js | 32 | ||||
-rw-r--r-- | deps/node/benchmark/http/set_header.js | 30 | ||||
-rw-r--r-- | deps/node/benchmark/http/simple.js | 26 | ||||
-rw-r--r-- | deps/node/benchmark/http/upgrade.js | 51 |
16 files changed, 0 insertions, 776 deletions
diff --git a/deps/node/benchmark/http/_chunky_http_client.js b/deps/node/benchmark/http/_chunky_http_client.js deleted file mode 100644 index 21418a7c..00000000 --- a/deps/node/benchmark/http/_chunky_http_client.js +++ /dev/null @@ -1,95 +0,0 @@ -'use strict'; - -// test HTTP throughput in fragmented header case -const common = require('../common.js'); -const net = require('net'); - -const bench = common.createBenchmark(main, { - len: [1, 4, 8, 16, 32, 64, 128], - n: [5, 50, 500, 2000], - type: ['send'], -}); - - -function main({ len, n }) { - var todo = []; - const headers = []; - // Chose 7 because 9 showed "Connection error" / "Connection closed" - // An odd number could result in a better length dispersion. - for (var i = 7; i <= 7 * 7 * 7; i *= 7) - headers.push('o'.repeat(i)); - - function WriteHTTPHeaders(channel, has_keep_alive, extra_header_count) { - todo = []; - todo.push('GET / HTTP/1.1'); - todo.push('Host: localhost'); - todo.push('Connection: keep-alive'); - todo.push('Accept: text/html,application/xhtml+xml,' + - 'application/xml;q=0.9,image/webp,*/*;q=0.8'); - todo.push('User-Agent: Mozilla/5.0 (X11; Linux x86_64) ' + - 'AppleWebKit/537.36 (KHTML, like Gecko) ' + - 'Chrome/39.0.2171.71 Safari/537.36'); - todo.push('Accept-Encoding: gzip, deflate, sdch'); - todo.push('Accept-Language: en-US,en;q=0.8'); - for (var i = 0; i < extra_header_count; i++) { - // Utilize first three powers of a small integer for an odd cycle and - // because the fourth power of some integers overloads the server. - todo.push(`X-Header-${i}: ${headers[i % 3]}`); - } - todo.push(''); - todo.push(''); - todo = todo.join('\r\n'); - // Using odd numbers in many places may increase length coverage. - const chunksize = 37; - for (i = 0; i < todo.length; i += chunksize) { - const cur = todo.slice(i, i + chunksize); - channel.write(cur); - } - } - - const min = 10; - var size = 0; - const mod = 317; - const mult = 17; - const add = 11; - var count = 0; - const PIPE = process.env.PIPE_NAME; - var socket = net.connect(PIPE, () => { - bench.start(); - WriteHTTPHeaders(socket, 1, len); - socket.setEncoding('utf8'); - socket.on('data', (d) => { - var did = false; - var pattern = 'HTTP/1.1 200 OK\r\n'; - if ((d.length === pattern.length && d === pattern) || - (d.length > pattern.length && - d.slice(0, pattern.length) === pattern)) { - did = true; - } else { - pattern = 'HTTP/1.1 '; - if ((d.length === pattern.length && d === pattern) || - (d.length > pattern.length && - d.slice(0, pattern.length) === pattern)) { - did = true; - } - } - size = (size * mult + add) % mod; - if (did) { - count += 1; - if (count === n) { - bench.end(count); - process.exit(0); - } else { - WriteHTTPHeaders(socket, 1, min + size); - } - } - }); - socket.on('close', () => { - console.log('Connection closed'); - }); - - socket.on('error', () => { - throw new Error('Connection error'); - }); - }); -} diff --git a/deps/node/benchmark/http/bench-parser.js b/deps/node/benchmark/http/bench-parser.js deleted file mode 100644 index a54f0efa..00000000 --- a/deps/node/benchmark/http/bench-parser.js +++ /dev/null @@ -1,53 +0,0 @@ -'use strict'; - -const common = require('../common'); - -const bench = common.createBenchmark(main, { - len: [4, 8, 16, 32], - n: [1e5] -}, { - flags: ['--expose-internals', '--no-warnings'] -}); - -function main({ len, n }) { - const { HTTPParser } = common.binding('http_parser'); - const REQUEST = HTTPParser.REQUEST; - const kOnHeaders = HTTPParser.kOnHeaders | 0; - const kOnHeadersComplete = HTTPParser.kOnHeadersComplete | 0; - const kOnBody = HTTPParser.kOnBody | 0; - const kOnMessageComplete = HTTPParser.kOnMessageComplete | 0; - const CRLF = '\r\n'; - - function processHeader(header, n) { - const parser = newParser(REQUEST); - - bench.start(); - for (var i = 0; i < n; i++) { - parser.execute(header, 0, header.length); - parser.reinitialize(REQUEST, i > 0); - } - bench.end(n); - } - - function newParser(type) { - const parser = new HTTPParser(type); - - parser.headers = []; - - parser[kOnHeaders] = function() { }; - parser[kOnHeadersComplete] = function() { }; - parser[kOnBody] = function() { }; - parser[kOnMessageComplete] = function() { }; - - return parser; - } - - let header = `GET /hello HTTP/1.1${CRLF}Content-Type: text/plain${CRLF}`; - - for (var i = 0; i < len; i++) { - header += `X-Filler${i}: ${Math.random().toString(36).substr(2)}${CRLF}`; - } - header += CRLF; - - processHeader(Buffer.from(header), n); -} diff --git a/deps/node/benchmark/http/check_invalid_header_char.js b/deps/node/benchmark/http/check_invalid_header_char.js deleted file mode 100644 index 46ca9f3d..00000000 --- a/deps/node/benchmark/http/check_invalid_header_char.js +++ /dev/null @@ -1,68 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const _checkInvalidHeaderChar = require('_http_common')._checkInvalidHeaderChar; - -const groupedInputs = { - // Representative set of inputs from an AcmeAir benchmark run: - // all valid strings, average length 14.4, stdev 13.0 - group_acmeair: [ - 'W/"2-d4cbb29"', 'OK', 'Express', 'X-HTTP-Method-Override', 'Express', - 'application/json', 'application/json; charset=utf-8', '206', 'OK', - 'sessionid=; Path=/', 'text/html; charset=utf-8', - 'text/html; charset=utf-8', '10', 'W/"a-eda64de5"', 'OK', 'Express', - 'application/json', 'application/json; charset=utf-8', '2', 'W/"2-d4cbb29"', - 'OK', 'Express', 'X-HTTP-Method-Override', 'sessionid=; Path=/', 'Express', - 'sessionid=; Path=/,sessionid=6b059402-d62f-4e6f-b3dd-ce5b9e487c39; Path=/', - 'text/html; charset=utf-8', 'text/html; charset=utf-8', '9', 'OK', - 'sessionid=; Path=/', 'text/html; charset=utf-8', - 'text/html; charset=utf-8', '10', 'W/"a-eda64de5"', 'OK', 'Express', - 'Express', 'X-HTTP-Method-Override', 'sessionid=; Path=/', - 'application/json', - ], - - // Put it here so the benchmark result lines will not be super long. - LONG_AND_INVALID: ['Here is a value that is really a folded header ' + - 'value\r\n this should be supported, but it is not currently'] -}; - -const inputs = [ - // Valid - '', - '1', - '\t\t\t\t\t\t\t\t\t\tFoo bar baz', - 'keep-alive', - 'close', - 'gzip', - '20091', - 'private', - 'text/html; charset=utf-8', - 'text/plain', - 'Sat, 07 May 2016 16:54:48 GMT', - 'SAMEORIGIN', - 'en-US', - - // Invalid - '中文呢', // unicode - 'foo\nbar', - '\x7F', -]; - -const bench = common.createBenchmark(main, { - input: inputs.concat(Object.keys(groupedInputs)), - n: [1e6], -}); - -function main({ n, input }) { - let inputs = [input]; - if (groupedInputs.hasOwnProperty(input)) { - inputs = groupedInputs[input]; - } - - const len = inputs.length; - bench.start(); - for (var i = 0; i < n; i++) { - _checkInvalidHeaderChar(inputs[i % len]); - } - bench.end(n); -} diff --git a/deps/node/benchmark/http/check_is_http_token.js b/deps/node/benchmark/http/check_is_http_token.js deleted file mode 100644 index eab07524..00000000 --- a/deps/node/benchmark/http/check_is_http_token.js +++ /dev/null @@ -1,49 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const _checkIsHttpToken = require('_http_common')._checkIsHttpToken; - -const bench = common.createBenchmark(main, { - key: [ - 'TCN', - 'ETag', - 'date', - 'Vary', - 'server', - 'Server', - 'status', - 'version', - 'Expires', - 'alt-svc', - 'location', - 'Connection', - 'Keep-Alive', - 'content-type', - 'Content-Type', - 'Cache-Control', - 'Last-Modified', - 'Accept-Ranges', - 'content-length', - 'x-frame-options', - 'x-xss-protection', - 'Content-Encoding', - 'Content-Location', - 'Transfer-Encoding', - 'alternate-protocol', - ':', // invalid input - '@@', - '中文呢', // unicode - '((((())))', // invalid - ':alternate-protocol', // fast bailout - 'alternate-protocol:', // slow bailout - ], - n: [1e6], -}); - -function main({ n, key }) { - bench.start(); - for (var i = 0; i < n; i++) { - _checkIsHttpToken(key); - } - bench.end(n); -} diff --git a/deps/node/benchmark/http/chunked.js b/deps/node/benchmark/http/chunked.js deleted file mode 100644 index 52b46057..00000000 --- a/deps/node/benchmark/http/chunked.js +++ /dev/null @@ -1,41 +0,0 @@ -// When calling .end(buffer) right away, this triggers a "hot path" -// optimization in http.js, to avoid an extra write call. -// -// However, the overhead of copying a large buffer is higher than -// the overhead of an extra write() call, so the hot path was not -// always as hot as it could be. -// -// Verify that our assumptions are valid. -'use strict'; - -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { - n: [1, 4, 8, 16], - len: [1, 64, 256], - c: [100] -}); - -function main({ len, n, c }) { - const http = require('http'); - const chunk = Buffer.alloc(len, '8'); - - const server = http.createServer((req, res) => { - function send(left) { - if (left === 0) return res.end(); - res.write(chunk); - setTimeout(() => { - send(left - 1); - }, 0); - } - send(n); - }); - - server.listen(common.PORT, () => { - bench.http({ - connections: c - }, () => { - server.close(); - }); - }); -} diff --git a/deps/node/benchmark/http/client-request-body.js b/deps/node/benchmark/http/client-request-body.js deleted file mode 100644 index b5ac2828..00000000 --- a/deps/node/benchmark/http/client-request-body.js +++ /dev/null @@ -1,67 +0,0 @@ -// Measure the time it takes for the HTTP client to send a request body. -'use strict'; - -const common = require('../common.js'); -const http = require('http'); - -const bench = common.createBenchmark(main, { - dur: [5], - type: ['asc', 'utf', 'buf'], - len: [32, 256, 1024], - method: ['write', 'end'] -}); - -function main({ dur, len, type, method }) { - var encoding; - var chunk; - switch (type) { - case 'buf': - chunk = Buffer.alloc(len, 'x'); - break; - case 'utf': - encoding = 'utf8'; - chunk = 'ü'.repeat(len / 2); - break; - case 'asc': - chunk = 'a'.repeat(len); - break; - } - - var nreqs = 0; - const options = { - headers: { 'Connection': 'keep-alive', 'Transfer-Encoding': 'chunked' }, - agent: new http.Agent({ maxSockets: 1 }), - host: '127.0.0.1', - port: common.PORT, - path: '/', - method: 'POST' - }; - - const server = http.createServer((req, res) => { - res.end(); - }); - server.listen(options.port, options.host, () => { - setTimeout(done, dur * 1000); - bench.start(); - pummel(); - }); - - function pummel() { - const req = http.request(options, (res) => { - nreqs++; - pummel(); // Line up next request. - res.resume(); - }); - if (method === 'write') { - req.write(chunk, encoding); - req.end(); - } else { - req.end(chunk, encoding); - } - } - - function done() { - bench.end(nreqs); - process.exit(0); - } -} diff --git a/deps/node/benchmark/http/cluster.js b/deps/node/benchmark/http/cluster.js deleted file mode 100644 index 35d0ba98..00000000 --- a/deps/node/benchmark/http/cluster.js +++ /dev/null @@ -1,41 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const PORT = common.PORT; - -const cluster = require('cluster'); -if (cluster.isMaster) { - var bench = common.createBenchmark(main, { - // unicode confuses ab on os x. - type: ['bytes', 'buffer'], - len: [4, 1024, 102400], - c: [50, 500] - }); -} else { - const port = parseInt(process.env.PORT || PORT); - require('../fixtures/simple-http-server.js').listen(port); -} - -function main({ type, len, c }) { - process.env.PORT = PORT; - var workers = 0; - const w1 = cluster.fork(); - const w2 = cluster.fork(); - - cluster.on('listening', () => { - workers++; - if (workers < 2) - return; - - setImmediate(() => { - const path = `/${type}/${len}`; - - bench.http({ - path: path, - connections: c - }, () => { - w1.destroy(); - w2.destroy(); - }); - }); - }); -} diff --git a/deps/node/benchmark/http/create-clientrequest.js b/deps/node/benchmark/http/create-clientrequest.js deleted file mode 100644 index 24d6e020..00000000 --- a/deps/node/benchmark/http/create-clientrequest.js +++ /dev/null @@ -1,59 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const { ClientRequest } = require('http'); -const assert = require('assert'); - -const types = Object.keys(common.urls) - .filter((i) => common.urls[i] - .startsWith('http://')); -const bench = common.createBenchmark(main, { - // Use 'url' to avoid name clash with other http benchmark - url: types.concat(['wpt']), - arg: ['URL', 'string', 'options'], - e: [1] -}); - -function noop() {} - -function main({ url: type, arg, e }) { - e = Number(e); - const data = common.bakeUrlData(type, e, false, false) - .filter((i) => i.startsWith('http://')); - const len = data.length; - let result; - switch (arg) { - case 'options': { - const options = data.map((i) => ({ - path: new URL(i).path, createConnection: noop - })); - bench.start(); - for (let i = 0; i < len; i++) { - result = new ClientRequest(options[i]); - } - bench.end(len); - break; - } - case 'URL': { - const options = data.map((i) => new URL(i)); - bench.start(); - for (let i = 0; i < len; i++) { - result = new ClientRequest(options[i], { createConnection: noop }); - } - bench.end(len); - break; - } - case 'string': { - bench.start(); - for (let i = 0; i < len; i++) { - result = new ClientRequest(data[i], { createConnection: noop }); - } - bench.end(len); - break; - } - default: { - throw new Error(`Unknown arg type ${arg}`); - } - } - assert.ok(result); -} diff --git a/deps/node/benchmark/http/end-vs-write-end.js b/deps/node/benchmark/http/end-vs-write-end.js deleted file mode 100644 index b4ca560b..00000000 --- a/deps/node/benchmark/http/end-vs-write-end.js +++ /dev/null @@ -1,57 +0,0 @@ -// When calling .end(buffer) right away, this triggers a "hot path" -// optimization in http.js, to avoid an extra write call. -// -// However, the overhead of copying a large buffer is higher than -// the overhead of an extra write() call, so the hot path was not -// always as hot as it could be. -// -// Verify that our assumptions are valid. -'use strict'; - -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { - type: ['asc', 'utf', 'buf'], - len: [64 * 1024, 128 * 1024, 256 * 1024, 1024 * 1024], - c: [100], - method: ['write', 'end'] -}); - -function main({ len, type, method, c }) { - const http = require('http'); - var chunk; - switch (type) { - case 'buf': - chunk = Buffer.alloc(len, 'x'); - break; - case 'utf': - chunk = 'ü'.repeat(len / 2); - break; - case 'asc': - chunk = 'a'.repeat(len); - break; - } - - function write(res) { - res.write(chunk); - res.end(); - } - - function end(res) { - res.end(chunk); - } - - const fn = method === 'write' ? write : end; - - const server = http.createServer((req, res) => { - fn(res); - }); - - server.listen(common.PORT, () => { - bench.http({ - connections: c - }, () => { - server.close(); - }); - }); -} diff --git a/deps/node/benchmark/http/headers.js b/deps/node/benchmark/http/headers.js deleted file mode 100644 index 8f611ae4..00000000 --- a/deps/node/benchmark/http/headers.js +++ /dev/null @@ -1,35 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const http = require('http'); - -const bench = common.createBenchmark(main, { - n: [10, 1000], - len: [1, 100], -}); - -function main({ len, n }) { - const headers = { - 'Connection': 'keep-alive', - 'Transfer-Encoding': 'chunked', - }; - - const Is = [ ...Array(n / len).keys() ]; - const Js = [ ...Array(len).keys() ]; - for (const i of Is) { - headers[`foo${i}`] = Js.map(() => `some header value ${i}`); - } - - const server = http.createServer((req, res) => { - res.writeHead(200, headers); - res.end(); - }); - server.listen(common.PORT, () => { - bench.http({ - path: '/', - connections: 10 - }, () => { - server.close(); - }); - }); -} diff --git a/deps/node/benchmark/http/http_server_for_chunky_client.js b/deps/node/benchmark/http/http_server_for_chunky_client.js deleted file mode 100644 index edcacf5d..00000000 --- a/deps/node/benchmark/http/http_server_for_chunky_client.js +++ /dev/null @@ -1,37 +0,0 @@ -'use strict'; - -const assert = require('assert'); -const http = require('http'); -const { fork } = require('child_process'); -const common = require('../common.js'); -const { PIPE } = require('../../test/common'); -const tmpdir = require('../../test/common/tmpdir'); -process.env.PIPE_NAME = PIPE; - -tmpdir.refresh(); - -var server; - -server = http.createServer((req, res) => { - const headers = { - 'content-type': 'text/plain', - 'content-length': '2' - }; - res.writeHead(200, headers); - res.end('ok'); -}); - -server.on('error', (err) => { - throw new Error(`server error: ${err}`); -}); -server.listen(PIPE); - -const child = fork( - `${__dirname}/_chunky_http_client.js`, - process.argv.slice(2) -); -child.on('message', common.sendResult); -child.on('close', (code) => { - server.close(); - assert.strictEqual(code, 0); -}); diff --git a/deps/node/benchmark/http/incoming_headers.js b/deps/node/benchmark/http/incoming_headers.js deleted file mode 100644 index 7d995576..00000000 --- a/deps/node/benchmark/http/incoming_headers.js +++ /dev/null @@ -1,35 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const http = require('http'); - -const bench = common.createBenchmark(main, { - // unicode confuses ab on os x. - c: [50, 500], - n: [0, 5, 20] -}); - -function main({ c, n }) { - const server = http.createServer((req, res) => { - res.end(); - }); - - server.listen(common.PORT, () => { - const headers = { - 'Content-Type': 'text/plain', - 'Accept': 'text/plain', - 'User-Agent': 'nodejs-benchmark', - 'Date': new Date().toString(), - 'Cache-Control': 'no-cache' - }; - for (let i = 0; i < n; i++) { - headers[`foo${i}`] = `some header value ${i}`; - } - bench.http({ - path: '/', - connections: c, - headers - }, () => { - server.close(); - }); - }); -} diff --git a/deps/node/benchmark/http/set-header.js b/deps/node/benchmark/http/set-header.js deleted file mode 100644 index 01cd8492..00000000 --- a/deps/node/benchmark/http/set-header.js +++ /dev/null @@ -1,32 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const PORT = common.PORT; - -const bench = common.createBenchmark(main, { - res: ['normal', 'setHeader', 'setHeaderWH'] -}); - -const type = 'bytes'; -const len = 4; -const chunks = 0; -const chunkedEnc = 0; -const c = 50; - -// normal: writeHead(status, {...}) -// setHeader: statusCode = status, setHeader(...) x2 -// setHeaderWH: setHeader(...), writeHead(status, ...) -function main({ res }) { - process.env.PORT = PORT; - var server = require('../fixtures/simple-http-server.js') - .listen(PORT) - .on('listening', () => { - const path = `/${type}/${len}/${chunks}/normal/${chunkedEnc}`; - - bench.http({ - path: path, - connections: c - }, () => { - server.close(); - }); - }); -} diff --git a/deps/node/benchmark/http/set_header.js b/deps/node/benchmark/http/set_header.js deleted file mode 100644 index 4129e4fe..00000000 --- a/deps/node/benchmark/http/set_header.js +++ /dev/null @@ -1,30 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const { OutgoingMessage } = require('_http_outgoing'); - -const bench = common.createBenchmark(main, { - value: [ - 'X-Powered-By', - 'Vary', - 'Set-Cookie', - 'Content-Type', - 'Content-Length', - 'Connection', - 'Transfer-Encoding', - ], - n: [1e6], -}); - -function main(conf) { - const n = +conf.n; - const value = conf.value; - - const og = new OutgoingMessage(); - - bench.start(); - for (var i = 0; i < n; i++) { - og.setHeader(value, ''); - } - bench.end(n); -} diff --git a/deps/node/benchmark/http/simple.js b/deps/node/benchmark/http/simple.js deleted file mode 100644 index c6faaaa9..00000000 --- a/deps/node/benchmark/http/simple.js +++ /dev/null @@ -1,26 +0,0 @@ -'use strict'; -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { - // unicode confuses ab on os x. - type: ['bytes', 'buffer'], - len: [4, 1024, 102400], - chunks: [1, 4], - c: [50, 500], - chunkedEnc: [1, 0] -}); - -function main({ type, len, chunks, c, chunkedEnc, res }) { - var server = require('../fixtures/simple-http-server.js') - .listen(common.PORT) - .on('listening', () => { - const path = `/${type}/${len}/${chunks}/normal/${chunkedEnc}`; - - bench.http({ - path: path, - connections: c - }, () => { - server.close(); - }); - }); -} diff --git a/deps/node/benchmark/http/upgrade.js b/deps/node/benchmark/http/upgrade.js deleted file mode 100644 index c286cdb2..00000000 --- a/deps/node/benchmark/http/upgrade.js +++ /dev/null @@ -1,51 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const net = require('net'); - -const bench = common.createBenchmark(main, { - n: [5, 1000] -}); - -const reqData = 'GET / HTTP/1.1\r\n' + - 'Upgrade: WebSocket\r\n' + - 'Connection: Upgrade\r\n' + - '\r\n' + - 'WjN}|M(6'; - -const resData = 'HTTP/1.1 101 Web Socket Protocol Handshake\r\n' + - 'Upgrade: WebSocket\r\n' + - 'Connection: Upgrade\r\n' + - '\r\n\r\n'; - -function main({ n }) { - var server = require('../fixtures/simple-http-server.js') - .listen(common.PORT) - .on('listening', () => { - bench.start(); - doBench(server.address(), n, () => { - bench.end(n); - server.close(); - }); - }) - .on('upgrade', (req, socket, upgradeHead) => { - socket.resume(); - socket.write(resData); - socket.end(); - }); -} - -function doBench(address, count, done) { - if (count === 0) { - done(); - return; - } - - const conn = net.createConnection(address.port); - conn.write(reqData); - conn.resume(); - - conn.on('end', () => { - doBench(address, count - 1, done); - }); -} |