Skip to content

Commit

Permalink
benchmark: (http(2)) refactor
Browse files Browse the repository at this point in the history
PR-URL: #18320
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
BridgeAR authored and MylesBorins committed Feb 21, 2018
1 parent 076b3d9 commit 28156e1
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 16 deletions.
3 changes: 0 additions & 3 deletions benchmark/http/bench-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;

Expand All @@ -26,7 +25,6 @@ function main({ len, n }) {
processHeader(Buffer.from(header), n);
}


function processHeader(header, n) {
const parser = newParser(REQUEST);

Expand All @@ -38,7 +36,6 @@ function processHeader(header, n) {
bench.end(n);
}


function newParser(type) {
const parser = new HTTPParser(type);

Expand Down
4 changes: 1 addition & 3 deletions benchmark/http/simple.js
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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}`;

Expand Down
2 changes: 0 additions & 2 deletions benchmark/http/upgrade.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const common = require('../common.js');
const PORT = common.PORT;
const net = require('net');

const bench = common.createBenchmark(main, {
Expand All @@ -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() {
Expand Down
3 changes: 1 addition & 2 deletions benchmark/http2/respond-with-fd.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const common = require('../common.js');
const PORT = common.PORT;
const path = require('path');
const fs = require('fs');

Expand All @@ -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,
Expand Down
5 changes: 1 addition & 4 deletions benchmark/http2/simple.js
Original file line number Diff line number Diff line change
@@ -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, {
Expand All @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions benchmark/http2/write.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const common = require('../common.js');
const PORT = common.PORT;

const bench = common.createBenchmark(main, {
streams: [100, 200, 1000],
Expand All @@ -26,7 +25,7 @@ function main({ streams, length, size }) {
}
write();
});
server.listen(PORT, () => {
server.listen(common.PORT, () => {
bench.http({
path: '/',
requests: 10000,
Expand Down

0 comments on commit 28156e1

Please sign in to comment.