mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
benchmark: (http(2)) refactor
PR-URL: https://github.com/nodejs/node/pull/18320 Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
076b3d9b0a
commit
28156e16d1
6 files changed
+4
-16
No files matched your search
@@ -14,7 +14,6 @@ const bench = common.createBenchmark(main, {
|
||||
n: [1e5],
|
||||
});
|
||||
|
||||
|
||||
function main({ len, n }) {
|
||||
var header = `GET /hello HTTP/1.1${CRLF}Content-Type: text/plain${CRLF}`;
|
||||
|
||||
@@ -26,7 +25,6 @@ function main({ len, n }) {
|
||||
processHeader(Buffer.from(header), n);
|
||||
}
|
||||
|
||||
|
||||
function processHeader(header, n) {
|
||||
const parser = newParser(REQUEST);
|
||||
|
||||
@@ -38,7 +36,6 @@ function processHeader(header, n) {
|
||||
bench.end(n);
|
||||
}
|
||||
|
||||
|
||||
function newParser(type) {
|
||||
const parser = new HTTPParser(type);
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
'use strict';
|
||||
const common = require('../common.js');
|
||||
const PORT = common.PORT;
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
// unicode confuses ab on os x.
|
||||
@@ -13,9 +12,8 @@ const bench = common.createBenchmark(main, {
|
||||
});
|
||||
|
||||
function main({ type, len, chunks, c, chunkedEnc, res }) {
|
||||
process.env.PORT = PORT;
|
||||
var server = require('../fixtures/simple-http-server.js')
|
||||
.listen(PORT)
|
||||
.listen(common.PORT)
|
||||
.on('listening', function() {
|
||||
const path = `/${type}/${len}/${chunks}/${res}/${chunkedEnc}`;
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const common = require('../common.js');
|
||||
const PORT = common.PORT;
|
||||
const net = require('net');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
@@ -20,7 +19,6 @@ const resData = 'HTTP/1.1 101 Web Socket Protocol Handshake\r\n' +
|
||||
'\r\n\r\n';
|
||||
|
||||
function main({ n }) {
|
||||
process.env.PORT = PORT;
|
||||
var server = require('../fixtures/simple-http-server.js')
|
||||
.listen(common.PORT)
|
||||
.on('listening', function() {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const common = require('../common.js');
|
||||
const PORT = common.PORT;
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
@@ -25,7 +24,7 @@ function main({ requests, streams, clients }) {
|
||||
stream.respondWithFD(fd);
|
||||
stream.on('error', (err) => {});
|
||||
});
|
||||
server.listen(PORT, () => {
|
||||
server.listen(common.PORT, () => {
|
||||
bench.http({
|
||||
path: '/',
|
||||
requests,
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
const common = require('../common.js');
|
||||
const PORT = common.PORT;
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const file = path.join(path.resolve(__dirname, '../fixtures'), 'alice.html');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
@@ -24,7 +21,7 @@ function main({ requests, streams, clients }) {
|
||||
out.pipe(stream);
|
||||
stream.on('error', (err) => {});
|
||||
});
|
||||
server.listen(PORT, () => {
|
||||
server.listen(common.PORT, () => {
|
||||
bench.http({
|
||||
path: '/',
|
||||
requests,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const common = require('../common.js');
|
||||
const PORT = common.PORT;
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
streams: [100, 200, 1000],
|
||||
@@ -26,7 +25,7 @@ function main({ streams, length, size }) {
|
||||
}
|
||||
write();
|
||||
});
|
||||
server.listen(PORT, () => {
|
||||
server.listen(common.PORT, () => {
|
||||
bench.http({
|
||||
path: '/',
|
||||
requests: 10000,
|
||||
|
||||
Reference in new issue
Block a user