Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
8d5f560
benchmark: (arrays) use destructuring
BridgeAR Dec 30, 2017
eb5a92d
benchmark: (assert) use destructuring
BridgeAR Dec 30, 2017
a48a321
benchmark: (url) use destructuring
BridgeAR Dec 30, 2017
52fc567
benchmark: (zlib) use destructuring
BridgeAR Dec 30, 2017
e6eb394
benchmark: (util/v8/vm) use destructuring
BridgeAR Dec 30, 2017
8e977c3
benchmark: (tls) use destructuring
BridgeAR Dec 30, 2017
0d05d11
benchmark: (timers) use destructuring
BridgeAR Dec 30, 2017
912458b
benchmark: (streams) use destructuring
BridgeAR Dec 30, 2017
1cc8db1
benchmark: (querystring) use destructuring
BridgeAR Dec 30, 2017
f30a2bd
benchmark: (process) use destructuring
BridgeAR Dec 30, 2017
b2e8cca
benchmark: (net) use destructuring
BridgeAR Dec 30, 2017
c5879c3
benchmark: (os) use destructuring
BridgeAR Dec 30, 2017
c5a1819
benchmark: (path) use destructuring
BridgeAR Dec 30, 2017
ed55a5e
benchmark: (string_decoder) use destructuring
BridgeAR Dec 30, 2017
430bb2c
benchmark: (http2) use destructuring
BridgeAR Dec 30, 2017
2f49067
benchmark: (misc) use destructuring
BridgeAR Dec 30, 2017
69bfcbc
benchmark: (http) use destructuring
BridgeAR Dec 30, 2017
cdfb609
benchmark: (fs) use destructuring
BridgeAR Dec 30, 2017
abc7eec
benchmark: (es) use destructuring
BridgeAR Dec 30, 2017
3011f0a
benchmark: (events) use destructuring
BridgeAR Dec 30, 2017
f2d920b
benchmark: (buffers) use destructuring
BridgeAR Dec 30, 2017
d766d57
benchmark: (child_process) use destructuring
BridgeAR Dec 30, 2017
59b5962
benchmark: (dgram) use destructuring
BridgeAR Dec 30, 2017
bf6ea9e
benchmark: (async_hooks/dns/cluster/domain/module) use destructuring
BridgeAR Dec 30, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
benchmark: (http) use destructuring
  • Loading branch information
BridgeAR committed Jan 19, 2018
commit 69bfcbcd79428bfcf41a858cdc8639fed2e5f581
6 changes: 2 additions & 4 deletions benchmark/http/_chunky_http_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ const bench = common.createBenchmark(main, {
});


function main(conf) {
const len = +conf.len;
const num = +conf.n;
function main({ len, n }) {
var todo = [];
const headers = [];
// Chose 7 because 9 showed "Connection error" / "Connection closed"
Expand Down Expand Up @@ -78,7 +76,7 @@ function main(conf) {
size = (size * mult + add) % mod;
if (did) {
count += 1;
if (count === num) {
if (count === n) {
bench.end(count);
process.exit(0);
} else {
Expand Down
4 changes: 1 addition & 3 deletions benchmark/http/bench-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ const bench = common.createBenchmark(main, {
});


function main(conf) {
const len = conf.len >>> 0;
const n = conf.n >>> 0;
function main({ len, n }) {
var header = `GET /hello HTTP/1.1${CRLF}Content-Type: text/plain${CRLF}`;

for (var i = 0; i < len; i++) {
Expand Down
5 changes: 1 addition & 4 deletions benchmark/http/check_invalid_header_char.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ const bench = common.createBenchmark(main, {
n: [1e6],
});

function main(conf) {
const n = +conf.n;
const key = conf.key;

function main({ n, key }) {
bench.start();
for (var i = 0; i < n; i++) {
_checkInvalidHeaderChar(key);
Expand Down
5 changes: 1 addition & 4 deletions benchmark/http/check_is_http_token.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ const bench = common.createBenchmark(main, {
n: [1e6],
});

function main(conf) {
const n = +conf.n;
const key = conf.key;

function main({ n, key }) {
bench.start();
for (var i = 0; i < n; i++) {
_checkIsHttpToken(key);
Expand Down
8 changes: 4 additions & 4 deletions benchmark/http/chunked.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ const bench = common.createBenchmark(main, {
c: [100]
});

function main(conf) {
function main({ len, n, c }) {
const http = require('http');
const chunk = Buffer.alloc(conf.len, '8');
const chunk = Buffer.alloc(len, '8');

const server = http.createServer(function(req, res) {
function send(left) {
Expand All @@ -28,12 +28,12 @@ function main(conf) {
send(left - 1);
}, 0);
}
send(conf.n);
send(n);
});

server.listen(common.PORT, function() {
bench.http({
connections: conf.c
connections: c
}, function() {
server.close();
});
Expand Down
9 changes: 3 additions & 6 deletions benchmark/http/client-request-body.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ const bench = common.createBenchmark(main, {
method: ['write', 'end']
});

function main(conf) {
const dur = +conf.dur;
const len = +conf.len;

function main({ dur, len, type, method }) {
var encoding;
var chunk;
switch (conf.type) {
switch (type) {
case 'buf':
chunk = Buffer.alloc(len, 'x');
break;
Expand Down Expand Up @@ -55,7 +52,7 @@ function main(conf) {
pummel(); // Line up next request.
res.resume();
});
if (conf.method === 'write') {
if (method === 'write') {
req.write(chunk, encoding);
req.end();
} else {
Expand Down
6 changes: 3 additions & 3 deletions benchmark/http/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if (cluster.isMaster) {
require('../fixtures/simple-http-server.js').listen(port);
}

function main(conf) {
function main({ type, len, c }) {
process.env.PORT = PORT;
var workers = 0;
const w1 = cluster.fork();
Expand All @@ -27,11 +27,11 @@ function main(conf) {
return;

setTimeout(function() {
const path = `/${conf.type}/${conf.len}`;
const path = `/${type}/${len}`;

bench.http({
path: path,
connections: conf.c
connections: c
}, function() {
w1.destroy();
w2.destroy();
Expand Down
5 changes: 1 addition & 4 deletions benchmark/http/create-clientrequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ const bench = common.createBenchmark(main, {
n: [1e6]
});

function main(conf) {
const len = +conf.len;
const n = +conf.n;

function main({ len, n }) {
const path = '/'.repeat(len);
const opts = { path: path, createConnection: function() {} };

Expand Down
11 changes: 5 additions & 6 deletions benchmark/http/end-vs-write-end.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ const bench = common.createBenchmark(main, {
method: ['write', 'end']
});

function main(conf) {
function main({ len, type, method, c }) {
const http = require('http');
var chunk;
const len = conf.len;
switch (conf.type) {
switch (type) {
case 'buf':
chunk = Buffer.alloc(len, 'x');
break;
Expand All @@ -42,15 +41,15 @@ function main(conf) {
res.end(chunk);
}

const method = conf.method === 'write' ? write : end;
const fn = method === 'write' ? write : end;

const server = http.createServer(function(req, res) {
method(res);
fn(res);
});

server.listen(common.PORT, function() {
bench.http({
connections: conf.c
connections: c
}, function() {
server.close();
});
Expand Down
7 changes: 3 additions & 4 deletions benchmark/http/simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@ const bench = common.createBenchmark(main, {
res: ['normal', 'setHeader', 'setHeaderWH']
});

function main(conf) {
function main({ type, len, chunks, c, chunkedEnc, res }) {
process.env.PORT = PORT;
var server = require('../fixtures/simple-http-server.js')
.listen(PORT)
.on('listening', function() {
const path =
`/${conf.type}/${conf.len}/${conf.chunks}/${conf.res}/${conf.chunkedEnc}`;
const path = `/${type}/${len}/${chunks}/${res}/${chunkedEnc}`;

bench.http({
path: path,
connections: conf.c
connections: c
}, function() {
server.close();
});
Expand Down