Skip to content

Commit 28156e1

Browse files
BridgeARMylesBorins
authored andcommitted
benchmark: (http(2)) refactor
PR-URL: #18320 Reviewed-By: James M Snell <[email protected]>
1 parent 076b3d9 commit 28156e1

File tree

6 files changed

+4
-16
lines changed

6 files changed

+4
-16
lines changed

benchmark/http/bench-parser.js

-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const bench = common.createBenchmark(main, {
1414
n: [1e5],
1515
});
1616

17-
1817
function main({ len, n }) {
1918
var header = `GET /hello HTTP/1.1${CRLF}Content-Type: text/plain${CRLF}`;
2019

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

29-
3028
function processHeader(header, n) {
3129
const parser = newParser(REQUEST);
3230

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

41-
4239
function newParser(type) {
4340
const parser = new HTTPParser(type);
4441

benchmark/http/simple.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22
const common = require('../common.js');
3-
const PORT = common.PORT;
43

54
const bench = common.createBenchmark(main, {
65
// unicode confuses ab on os x.
@@ -13,9 +12,8 @@ const bench = common.createBenchmark(main, {
1312
});
1413

1514
function main({ type, len, chunks, c, chunkedEnc, res }) {
16-
process.env.PORT = PORT;
1715
var server = require('../fixtures/simple-http-server.js')
18-
.listen(PORT)
16+
.listen(common.PORT)
1917
.on('listening', function() {
2018
const path = `/${type}/${len}/${chunks}/${res}/${chunkedEnc}`;
2119

benchmark/http/upgrade.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22

33
const common = require('../common.js');
4-
const PORT = common.PORT;
54
const net = require('net');
65

76
const bench = common.createBenchmark(main, {
@@ -20,7 +19,6 @@ const resData = 'HTTP/1.1 101 Web Socket Protocol Handshake\r\n' +
2019
'\r\n\r\n';
2120

2221
function main({ n }) {
23-
process.env.PORT = PORT;
2422
var server = require('../fixtures/simple-http-server.js')
2523
.listen(common.PORT)
2624
.on('listening', function() {

benchmark/http2/respond-with-fd.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22

33
const common = require('../common.js');
4-
const PORT = common.PORT;
54
const path = require('path');
65
const fs = require('fs');
76

@@ -25,7 +24,7 @@ function main({ requests, streams, clients }) {
2524
stream.respondWithFD(fd);
2625
stream.on('error', (err) => {});
2726
});
28-
server.listen(PORT, () => {
27+
server.listen(common.PORT, () => {
2928
bench.http({
3029
path: '/',
3130
requests,

benchmark/http2/simple.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
'use strict';
22

33
const common = require('../common.js');
4-
const PORT = common.PORT;
5-
64
const path = require('path');
75
const fs = require('fs');
8-
96
const file = path.join(path.resolve(__dirname, '../fixtures'), 'alice.html');
107

118
const bench = common.createBenchmark(main, {
@@ -24,7 +21,7 @@ function main({ requests, streams, clients }) {
2421
out.pipe(stream);
2522
stream.on('error', (err) => {});
2623
});
27-
server.listen(PORT, () => {
24+
server.listen(common.PORT, () => {
2825
bench.http({
2926
path: '/',
3027
requests,

benchmark/http2/write.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22

33
const common = require('../common.js');
4-
const PORT = common.PORT;
54

65
const bench = common.createBenchmark(main, {
76
streams: [100, 200, 1000],
@@ -26,7 +25,7 @@ function main({ streams, length, size }) {
2625
}
2726
write();
2827
});
29-
server.listen(PORT, () => {
28+
server.listen(common.PORT, () => {
3029
bench.http({
3130
path: '/',
3231
requests: 10000,

0 commit comments

Comments
 (0)