summaryrefslogtreecommitdiff
path: root/benchmark/http
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2017-09-13 22:48:53 -0300
committerRuben Bridgewater <ruben@bridgewater.de>2017-09-19 21:14:38 -0300
commite167ab71fb113fa38866dd11aa99af7079fb463c (patch)
tree3d91ca0f6e60d08fcab70833b851335e41b53cd0 /benchmark/http
parentb1c8f15c5f169e021f7c46eb7b219de95fe97603 (diff)
downloadandroid-node-v8-e167ab71fb113fa38866dd11aa99af7079fb463c.tar.gz
android-node-v8-e167ab71fb113fa38866dd11aa99af7079fb463c.tar.bz2
android-node-v8-e167ab71fb113fa38866dd11aa99af7079fb463c.zip
benchmark: var to const
PR-URL: https://github.com/nodejs/node/pull/13757 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Diffstat (limited to 'benchmark/http')
-rw-r--r--benchmark/http/_chunky_http_client.js26
-rw-r--r--benchmark/http/check_invalid_header_char.js4
-rw-r--r--benchmark/http/check_is_http_token.js4
-rw-r--r--benchmark/http/chunked.js8
-rw-r--r--benchmark/http/client-request-body.js16
-rw-r--r--benchmark/http/cluster.js14
-rw-r--r--benchmark/http/create-clientrequest.js14
-rw-r--r--benchmark/http/end-vs-write-end.js10
-rw-r--r--benchmark/http/http_server_for_chunky_client.js12
-rw-r--r--benchmark/http/simple.js8
10 files changed, 58 insertions, 58 deletions
diff --git a/benchmark/http/_chunky_http_client.js b/benchmark/http/_chunky_http_client.js
index d7c4e193c8..ee1f4f8caa 100644
--- a/benchmark/http/_chunky_http_client.js
+++ b/benchmark/http/_chunky_http_client.js
@@ -1,10 +1,10 @@
'use strict';
// test HTTP throughput in fragmented header case
-var common = require('../common.js');
-var net = require('net');
+const common = require('../common.js');
+const net = require('net');
-var bench = common.createBenchmark(main, {
+const bench = common.createBenchmark(main, {
len: [1, 4, 8, 16, 32, 64, 128],
n: [5, 50, 500, 2000],
type: ['send'],
@@ -12,10 +12,10 @@ var bench = common.createBenchmark(main, {
function main(conf) {
- var len = +conf.len;
- var num = +conf.n;
+ const len = +conf.len;
+ const num = +conf.n;
var todo = [];
- var headers = [];
+ 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)
@@ -42,20 +42,20 @@ function main(conf) {
todo.push('');
todo = todo.join('\r\n');
// Using odd numbers in many places may increase length coverage.
- var chunksize = 37;
+ const chunksize = 37;
for (i = 0; i < todo.length; i += chunksize) {
- var cur = todo.slice(i, i + chunksize);
+ const cur = todo.slice(i, i + chunksize);
channel.write(cur);
}
}
- var min = 10;
+ const min = 10;
var size = 0;
- var mod = 317;
- var mult = 17;
- var add = 11;
+ const mod = 317;
+ const mult = 17;
+ const add = 11;
var count = 0;
- var PIPE = process.env.PIPE_NAME;
+ const PIPE = process.env.PIPE_NAME;
var socket = net.connect(PIPE, function() {
bench.start();
WriteHTTPHeaders(socket, 1, len);
diff --git a/benchmark/http/check_invalid_header_char.js b/benchmark/http/check_invalid_header_char.js
index 7b9c08bd17..d71bc6fc60 100644
--- a/benchmark/http/check_invalid_header_char.js
+++ b/benchmark/http/check_invalid_header_char.js
@@ -31,8 +31,8 @@ const bench = common.createBenchmark(main, {
});
function main(conf) {
- var n = +conf.n;
- var key = conf.key;
+ const n = +conf.n;
+ const key = conf.key;
bench.start();
for (var i = 0; i < n; i++) {
diff --git a/benchmark/http/check_is_http_token.js b/benchmark/http/check_is_http_token.js
index 9e0b8279b5..92df3445b4 100644
--- a/benchmark/http/check_is_http_token.js
+++ b/benchmark/http/check_is_http_token.js
@@ -41,8 +41,8 @@ const bench = common.createBenchmark(main, {
});
function main(conf) {
- var n = +conf.n;
- var key = conf.key;
+ const n = +conf.n;
+ const key = conf.key;
bench.start();
for (var i = 0; i < n; i++) {
diff --git a/benchmark/http/chunked.js b/benchmark/http/chunked.js
index 34a06a1a6d..1056f456ef 100644
--- a/benchmark/http/chunked.js
+++ b/benchmark/http/chunked.js
@@ -8,9 +8,9 @@
// Verify that our assumptions are valid.
'use strict';
-var common = require('../common.js');
+const common = require('../common.js');
-var bench = common.createBenchmark(main, {
+const bench = common.createBenchmark(main, {
n: [1, 4, 8, 16],
len: [1, 64, 256],
c: [100]
@@ -18,9 +18,9 @@ var bench = common.createBenchmark(main, {
function main(conf) {
const http = require('http');
- var chunk = Buffer.alloc(conf.len, '8');
+ const chunk = Buffer.alloc(conf.len, '8');
- var server = http.createServer(function(req, res) {
+ const server = http.createServer(function(req, res) {
function send(left) {
if (left === 0) return res.end();
res.write(chunk);
diff --git a/benchmark/http/client-request-body.js b/benchmark/http/client-request-body.js
index d521c8a2c8..a6849580cf 100644
--- a/benchmark/http/client-request-body.js
+++ b/benchmark/http/client-request-body.js
@@ -1,10 +1,10 @@
// Measure the time it takes for the HTTP client to send a request body.
'use strict';
-var common = require('../common.js');
-var http = require('http');
+const common = require('../common.js');
+const http = require('http');
-var bench = common.createBenchmark(main, {
+const bench = common.createBenchmark(main, {
dur: [5],
type: ['asc', 'utf', 'buf'],
len: [32, 256, 1024],
@@ -12,8 +12,8 @@ var bench = common.createBenchmark(main, {
});
function main(conf) {
- var dur = +conf.dur;
- var len = +conf.len;
+ const dur = +conf.dur;
+ const len = +conf.len;
var encoding;
var chunk;
@@ -31,7 +31,7 @@ function main(conf) {
}
var nreqs = 0;
- var options = {
+ const options = {
headers: { 'Connection': 'keep-alive', 'Transfer-Encoding': 'chunked' },
agent: new http.Agent({ maxSockets: 1 }),
host: '127.0.0.1',
@@ -40,7 +40,7 @@ function main(conf) {
method: 'POST'
};
- var server = http.createServer(function(req, res) {
+ const server = http.createServer(function(req, res) {
res.end();
});
server.listen(options.port, options.host, function() {
@@ -50,7 +50,7 @@ function main(conf) {
});
function pummel() {
- var req = http.request(options, function(res) {
+ const req = http.request(options, function(res) {
nreqs++;
pummel(); // Line up next request.
res.resume();
diff --git a/benchmark/http/cluster.js b/benchmark/http/cluster.js
index 3a9392c422..352b1d2645 100644
--- a/benchmark/http/cluster.js
+++ b/benchmark/http/cluster.js
@@ -1,8 +1,8 @@
'use strict';
-var common = require('../common.js');
-var PORT = common.PORT;
+const common = require('../common.js');
+const PORT = common.PORT;
-var cluster = require('cluster');
+const cluster = require('cluster');
if (cluster.isMaster) {
var bench = common.createBenchmark(main, {
// unicode confuses ab on os x.
@@ -11,15 +11,15 @@ if (cluster.isMaster) {
c: [50, 500]
});
} else {
- var port = parseInt(process.env.PORT || PORT);
+ const port = parseInt(process.env.PORT || PORT);
require('../fixtures/simple-http-server.js').listen(port);
}
function main(conf) {
process.env.PORT = PORT;
var workers = 0;
- var w1 = cluster.fork();
- var w2 = cluster.fork();
+ const w1 = cluster.fork();
+ const w2 = cluster.fork();
cluster.on('listening', function() {
workers++;
@@ -27,7 +27,7 @@ function main(conf) {
return;
setTimeout(function() {
- var path = `/${conf.type}/${conf.len}`;
+ const path = `/${conf.type}/${conf.len}`;
bench.http({
path: path,
diff --git a/benchmark/http/create-clientrequest.js b/benchmark/http/create-clientrequest.js
index f40ff9155d..d19a6fb434 100644
--- a/benchmark/http/create-clientrequest.js
+++ b/benchmark/http/create-clientrequest.js
@@ -1,19 +1,19 @@
'use strict';
-var common = require('../common.js');
-var ClientRequest = require('http').ClientRequest;
+const common = require('../common.js');
+const ClientRequest = require('http').ClientRequest;
-var bench = common.createBenchmark(main, {
+const bench = common.createBenchmark(main, {
len: [1, 8, 16, 32, 64, 128],
n: [1e6]
});
function main(conf) {
- var len = +conf.len;
- var n = +conf.n;
+ const len = +conf.len;
+ const n = +conf.n;
- var path = '/'.repeat(len);
- var opts = { path: path, createConnection: function() {} };
+ const path = '/'.repeat(len);
+ const opts = { path: path, createConnection: function() {} };
bench.start();
for (var i = 0; i < n; i++) {
diff --git a/benchmark/http/end-vs-write-end.js b/benchmark/http/end-vs-write-end.js
index 163ad595a9..b7db1eaa78 100644
--- a/benchmark/http/end-vs-write-end.js
+++ b/benchmark/http/end-vs-write-end.js
@@ -8,9 +8,9 @@
// Verify that our assumptions are valid.
'use strict';
-var common = require('../common.js');
+const common = require('../common.js');
-var bench = common.createBenchmark(main, {
+const bench = common.createBenchmark(main, {
type: ['asc', 'utf', 'buf'],
len: [64 * 1024, 128 * 1024, 256 * 1024, 1024 * 1024],
c: [100],
@@ -20,7 +20,7 @@ var bench = common.createBenchmark(main, {
function main(conf) {
const http = require('http');
var chunk;
- var len = conf.len;
+ const len = conf.len;
switch (conf.type) {
case 'buf':
chunk = Buffer.alloc(len, 'x');
@@ -42,9 +42,9 @@ function main(conf) {
res.end(chunk);
}
- var method = conf.method === 'write' ? write : end;
+ const method = conf.method === 'write' ? write : end;
- var server = http.createServer(function(req, res) {
+ const server = http.createServer(function(req, res) {
method(res);
});
diff --git a/benchmark/http/http_server_for_chunky_client.js b/benchmark/http/http_server_for_chunky_client.js
index cc632c02ec..f079544e03 100644
--- a/benchmark/http/http_server_for_chunky_client.js
+++ b/benchmark/http/http_server_for_chunky_client.js
@@ -1,10 +1,10 @@
'use strict';
-var assert = require('assert');
-var http = require('http');
-var fs = require('fs');
-var { fork } = require('child_process');
-var common = require('../common.js');
+const assert = require('assert');
+const http = require('http');
+const fs = require('fs');
+const { fork } = require('child_process');
+const common = require('../common.js');
const { PIPE, tmpDir } = require('../../test/common');
process.env.PIPE_NAME = PIPE;
@@ -20,7 +20,7 @@ try {
} catch (e) { /* ignore */ }
server = http.createServer(function(req, res) {
- var headers = {
+ const headers = {
'content-type': 'text/plain',
'content-length': '2'
};
diff --git a/benchmark/http/simple.js b/benchmark/http/simple.js
index 6dc69a2d8f..238cd1885d 100644
--- a/benchmark/http/simple.js
+++ b/benchmark/http/simple.js
@@ -1,8 +1,8 @@
'use strict';
-var common = require('../common.js');
-var PORT = common.PORT;
+const common = require('../common.js');
+const PORT = common.PORT;
-var bench = common.createBenchmark(main, {
+const bench = common.createBenchmark(main, {
// unicode confuses ab on os x.
type: ['bytes', 'buffer'],
len: [4, 1024, 102400],
@@ -17,7 +17,7 @@ function main(conf) {
var server = require('../fixtures/simple-http-server.js')
.listen(process.env.PORT || common.PORT)
.on('listening', function() {
- var path =
+ const path =
`/${conf.type}/${conf.len}/${conf.chunks}/${conf.res}/${conf.chunkedEnc}`;
bench.http({