tools,benchmark: increase lint compliance
In the hopes of soon having the benchmark code linted, this change groups all the likely non-controversial lint-compliance changes such as indentation, semi-colon usage, and single-vs.-double quotation marks. Other lint rules may have subtle performance implications in the V8 currently shipped with Node.js. Those changes will require more careful review and will be in a separate change. PR-URL: https://github.com/nodejs/node/pull/5429 Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Brian White <mscdex@mscdex.net>
This commit is contained in:
parent
7fc6645982
commit
dcfda1007b
@ -44,7 +44,7 @@ function main(conf) {
|
|||||||
var r = Buffer.byteLength(strings[index], encoding);
|
var r = Buffer.byteLength(strings[index], encoding);
|
||||||
|
|
||||||
if (r !== results[index])
|
if (r !== results[index])
|
||||||
throw Error('incorrect return value');
|
throw new Error('incorrect return value');
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
}
|
}
|
||||||
|
@ -22,10 +22,10 @@ function main(conf) {
|
|||||||
|
|
||||||
buff.writeDoubleLE(0, 0, noAssert);
|
buff.writeDoubleLE(0, 0, noAssert);
|
||||||
var testFunction = new Function('buff', [
|
var testFunction = new Function('buff', [
|
||||||
"for (var i = 0; i !== " + len + "; i++) {",
|
'for (var i = 0; i !== ' + len + '; i++) {',
|
||||||
" buff." + fn + "(0, " + JSON.stringify(noAssert) + ");",
|
' buff.' + fn + '(0, ' + JSON.stringify(noAssert) + ');',
|
||||||
"}"
|
'}'
|
||||||
].join("\n"));
|
].join('\n'));
|
||||||
bench.start();
|
bench.start();
|
||||||
testFunction(buff);
|
testFunction(buff);
|
||||||
bench.end(len / 1e6);
|
bench.end(len / 1e6);
|
||||||
|
@ -48,10 +48,10 @@ function main(conf) {
|
|||||||
function benchInt(buff, fn, len, noAssert) {
|
function benchInt(buff, fn, len, noAssert) {
|
||||||
var m = mod[fn];
|
var m = mod[fn];
|
||||||
var testFunction = new Function('buff', [
|
var testFunction = new Function('buff', [
|
||||||
"for (var i = 0; i !== " + len + "; i++) {",
|
'for (var i = 0; i !== ' + len + '; i++) {',
|
||||||
" buff." + fn + "(i & " + m + ", 0, " + JSON.stringify(noAssert) + ");",
|
' buff.' + fn + '(i & ' + m + ', 0, ' + JSON.stringify(noAssert) + ');',
|
||||||
"}"
|
'}'
|
||||||
].join("\n"));
|
].join('\n'));
|
||||||
bench.start();
|
bench.start();
|
||||||
testFunction(buff);
|
testFunction(buff);
|
||||||
bench.end(len / 1e6);
|
bench.end(len / 1e6);
|
||||||
@ -59,10 +59,10 @@ function benchInt(buff, fn, len, noAssert) {
|
|||||||
|
|
||||||
function benchFloat(buff, fn, len, noAssert) {
|
function benchFloat(buff, fn, len, noAssert) {
|
||||||
var testFunction = new Function('buff', [
|
var testFunction = new Function('buff', [
|
||||||
"for (var i = 0; i !== " + len + "; i++) {",
|
'for (var i = 0; i !== ' + len + '; i++) {',
|
||||||
" buff." + fn + "(i, 0, " + JSON.stringify(noAssert) + ");",
|
' buff.' + fn + '(i, 0, ' + JSON.stringify(noAssert) + ');',
|
||||||
"}"
|
'}'
|
||||||
].join("\n"));
|
].join('\n'));
|
||||||
bench.start();
|
bench.start();
|
||||||
testFunction(buff);
|
testFunction(buff);
|
||||||
bench.end(len / 1e6);
|
bench.end(len / 1e6);
|
||||||
|
@ -121,7 +121,7 @@ Benchmark.prototype.http = function(p, args, cb) {
|
|||||||
|
|
||||||
if (code) {
|
if (code) {
|
||||||
console.error('wrk failed with ' + code);
|
console.error('wrk failed with ' + code);
|
||||||
process.exit(code)
|
process.exit(code);
|
||||||
}
|
}
|
||||||
var match = out.match(regexp);
|
var match = out.match(regexp);
|
||||||
var qps = match && +match[1];
|
var qps = match && +match[1];
|
||||||
@ -141,8 +141,6 @@ Benchmark.prototype._run = function() {
|
|||||||
// some options weren't set.
|
// some options weren't set.
|
||||||
// run with all combinations
|
// run with all combinations
|
||||||
var main = require.main.filename;
|
var main = require.main.filename;
|
||||||
var settings = [];
|
|
||||||
var queueLen = 1;
|
|
||||||
var options = this.options;
|
var options = this.options;
|
||||||
|
|
||||||
var queue = Object.keys(options).reduce(function(set, key) {
|
var queue = Object.keys(options).reduce(function(set, key) {
|
||||||
@ -210,7 +208,7 @@ function parseOpts(options) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
return num === 0 ? conf : null;
|
return num === 0 ? conf : null;
|
||||||
};
|
}
|
||||||
|
|
||||||
Benchmark.prototype.start = function() {
|
Benchmark.prototype.start = function() {
|
||||||
if (this._started)
|
if (this._started)
|
||||||
|
@ -31,7 +31,7 @@ function AEAD_Bench(cipher, message, associate_data, key, iv, n, len) {
|
|||||||
var bob = crypto.createDecipheriv(cipher, key, iv);
|
var bob = crypto.createDecipheriv(cipher, key, iv);
|
||||||
bob.setAuthTag(tag);
|
bob.setAuthTag(tag);
|
||||||
bob.setAAD(associate_data);
|
bob.setAAD(associate_data);
|
||||||
var clear = bob.update(enc);
|
bob.update(enc);
|
||||||
bob.final();
|
bob.final();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,6 @@ function legacyWrite(alice, bob, message, encoding, writes) {
|
|||||||
written += dec.length;
|
written += dec.length;
|
||||||
dec = bob.final();
|
dec = bob.final();
|
||||||
written += dec.length;
|
written += dec.length;
|
||||||
var bits = written * 8;
|
|
||||||
var gbits = written / (1024 * 1024 * 1024);
|
var gbits = written / (1024 * 1024 * 1024);
|
||||||
bench.end(gbits);
|
bench.end(gbits);
|
||||||
}
|
}
|
||||||
|
@ -21,9 +21,6 @@ function main(conf) {
|
|||||||
api = 'legacy';
|
api = 'legacy';
|
||||||
}
|
}
|
||||||
|
|
||||||
var crypto = require('crypto');
|
|
||||||
var assert = require('assert');
|
|
||||||
|
|
||||||
var message;
|
var message;
|
||||||
var encoding;
|
var encoding;
|
||||||
switch (conf.type) {
|
switch (conf.type) {
|
||||||
|
@ -20,9 +20,6 @@ function main(conf) {
|
|||||||
api = 'legacy';
|
api = 'legacy';
|
||||||
}
|
}
|
||||||
|
|
||||||
var crypto = require('crypto');
|
|
||||||
var assert = require('assert');
|
|
||||||
|
|
||||||
var message;
|
var message;
|
||||||
var encoding;
|
var encoding;
|
||||||
switch (conf.type) {
|
switch (conf.type) {
|
||||||
|
@ -23,7 +23,6 @@ var bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var crypto = require('crypto');
|
|
||||||
var message = (new Buffer(conf.len)).fill('b');
|
var message = (new Buffer(conf.len)).fill('b');
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
@ -39,7 +38,7 @@ function StreamWrite(algo, keylen, message, n, len) {
|
|||||||
var publicKey = RSA_PublicPem[keylen];
|
var publicKey = RSA_PublicPem[keylen];
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
var enc = crypto.privateEncrypt(privateKey, message);
|
var enc = crypto.privateEncrypt(privateKey, message);
|
||||||
var clear = crypto.publicDecrypt(publicKey, enc);
|
crypto.publicDecrypt(publicKey, enc);
|
||||||
}
|
}
|
||||||
|
|
||||||
bench.end(kbits);
|
bench.end(kbits);
|
||||||
|
@ -24,7 +24,6 @@ var bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var crypto = require('crypto');
|
|
||||||
var message = (new Buffer(conf.len)).fill('b');
|
var message = (new Buffer(conf.len)).fill('b');
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
@ -37,7 +36,6 @@ function StreamWrite(algo, keylen, message, writes, len) {
|
|||||||
var kbits = bits / (1024);
|
var kbits = bits / (1024);
|
||||||
|
|
||||||
var privateKey = RSA_PrivatePem[keylen];
|
var privateKey = RSA_PrivatePem[keylen];
|
||||||
var publicKey = RSA_PublicPem[keylen];
|
|
||||||
var s = crypto.createSign(algo);
|
var s = crypto.createSign(algo);
|
||||||
var v = crypto.createVerify(algo);
|
var v = crypto.createVerify(algo);
|
||||||
|
|
||||||
@ -46,7 +44,7 @@ function StreamWrite(algo, keylen, message, writes, len) {
|
|||||||
v.update(message);
|
v.update(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
var sign = s.sign(privateKey, 'binary');
|
s.sign(privateKey, 'binary');
|
||||||
s.end();
|
s.end();
|
||||||
v.end();
|
v.end();
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@ var num;
|
|||||||
var type;
|
var type;
|
||||||
var chunk;
|
var chunk;
|
||||||
var chunks;
|
var chunks;
|
||||||
var encoding;
|
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
dur = +conf.dur;
|
dur = +conf.dur;
|
||||||
@ -30,7 +29,7 @@ function main(conf) {
|
|||||||
type = conf.type;
|
type = conf.type;
|
||||||
chunks = +conf.chunks;
|
chunks = +conf.chunks;
|
||||||
|
|
||||||
chunk = []
|
chunk = [];
|
||||||
for (var i = 0; i < chunks; i++) {
|
for (var i = 0; i < chunks; i++) {
|
||||||
chunk.push(new Buffer(Math.round(len / chunks)));
|
chunk.push(new Buffer(Math.round(len / chunks)));
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ var num;
|
|||||||
var type;
|
var type;
|
||||||
var chunk;
|
var chunk;
|
||||||
var chunks;
|
var chunks;
|
||||||
var encoding;
|
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
dur = +conf.dur;
|
dur = +conf.dur;
|
||||||
@ -30,7 +29,7 @@ function main(conf) {
|
|||||||
type = conf.type;
|
type = conf.type;
|
||||||
chunks = +conf.chunks;
|
chunks = +conf.chunks;
|
||||||
|
|
||||||
chunk = []
|
chunk = [];
|
||||||
for (var i = 0; i < chunks; i++) {
|
for (var i = 0; i < chunks; i++) {
|
||||||
chunk.push(new Buffer(Math.round(len / chunks)));
|
chunk.push(new Buffer(Math.round(len / chunks)));
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ var len;
|
|||||||
var num;
|
var num;
|
||||||
var type;
|
var type;
|
||||||
var chunk;
|
var chunk;
|
||||||
var encoding;
|
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
dur = +conf.dur;
|
dur = +conf.dur;
|
||||||
|
@ -19,7 +19,6 @@ var len;
|
|||||||
var num;
|
var num;
|
||||||
var type;
|
var type;
|
||||||
var chunk;
|
var chunk;
|
||||||
var encoding;
|
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
dur = +conf.dur;
|
dur = +conf.dur;
|
||||||
|
@ -12,7 +12,7 @@ var gargs = [1, 2, 3];
|
|||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
|
|
||||||
var args, ret, n = +conf.n;
|
var args, n = +conf.n;
|
||||||
var myArguments = gargs.slice(0, conf.arguments);
|
var myArguments = gargs.slice(0, conf.arguments);
|
||||||
bench.start();
|
bench.start();
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ function main(conf) {
|
|||||||
var n = conf.n | 0;
|
var n = conf.n | 0;
|
||||||
|
|
||||||
var ee = new EventEmitter();
|
var ee = new EventEmitter();
|
||||||
var listeners = [];
|
|
||||||
|
|
||||||
for (var k = 0; k < 10; k += 1)
|
for (var k = 0; k < 10; k += 1)
|
||||||
ee.on('dummy', function() {});
|
ee.on('dummy', function() {});
|
||||||
|
@ -14,7 +14,7 @@ function main(conf) {
|
|||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i += 1) {
|
for (var i = 0; i < n; i += 1) {
|
||||||
var r = ee.listenerCount('dummy');
|
ee.listenerCount('dummy');
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ function main(conf) {
|
|||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i += 1) {
|
for (var i = 0; i < n; i += 1) {
|
||||||
var r = ee.listeners('dummy');
|
ee.listeners('dummy');
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ function main(conf) {
|
|||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i += 1) {
|
for (var i = 0; i < n; i += 1) {
|
||||||
var r = ee.listeners('dummy');
|
ee.listeners('dummy');
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
}
|
}
|
||||||
|
@ -49,11 +49,10 @@ function runTest(dur, size, type) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
var writes = 0;
|
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
try { fs.unlinkSync('write_stream_throughput'); } catch (e) {}
|
try { fs.unlinkSync('write_stream_throughput'); } catch (e) {}
|
||||||
|
|
||||||
var start
|
var start;
|
||||||
var end;
|
var end;
|
||||||
function done() {
|
function done() {
|
||||||
var time = end[0] + end[1] / 1E9;
|
var time = end[0] + end[1] / 1E9;
|
||||||
|
@ -15,7 +15,6 @@ var bench = common.createBenchmark(main, {
|
|||||||
function main(conf) {
|
function main(conf) {
|
||||||
var len = +conf.len;
|
var len = +conf.len;
|
||||||
var num = +conf.num;
|
var num = +conf.num;
|
||||||
var type = conf.type;
|
|
||||||
var todo = [];
|
var todo = [];
|
||||||
var headers = [];
|
var headers = [];
|
||||||
// Chose 7 because 9 showed "Connection error" / "Connection closed"
|
// Chose 7 because 9 showed "Connection error" / "Connection closed"
|
||||||
@ -24,7 +23,7 @@ function main(conf) {
|
|||||||
headers.push(Array(i + 1).join('o'));
|
headers.push(Array(i + 1).join('o'));
|
||||||
|
|
||||||
function WriteHTTPHeaders(channel, has_keep_alive, extra_header_count) {
|
function WriteHTTPHeaders(channel, has_keep_alive, extra_header_count) {
|
||||||
todo = []
|
todo = [];
|
||||||
todo.push('GET / HTTP/1.1');
|
todo.push('GET / HTTP/1.1');
|
||||||
todo.push('Host: localhost');
|
todo.push('Host: localhost');
|
||||||
todo.push('Connection: keep-alive');
|
todo.push('Connection: keep-alive');
|
||||||
@ -63,7 +62,7 @@ function main(conf) {
|
|||||||
var socket = net.connect(PIPE, function() {
|
var socket = net.connect(PIPE, function() {
|
||||||
bench.start();
|
bench.start();
|
||||||
WriteHTTPHeaders(socket, 1, len);
|
WriteHTTPHeaders(socket, 1, len);
|
||||||
socket.setEncoding('utf8')
|
socket.setEncoding('utf8');
|
||||||
socket.on('data', function(d) {
|
socket.on('data', function(d) {
|
||||||
var did = false;
|
var did = false;
|
||||||
var pattern = 'HTTP/1.1 200 OK\r\n';
|
var pattern = 'HTTP/1.1 200 OK\r\n';
|
||||||
@ -73,7 +72,7 @@ function main(conf) {
|
|||||||
success += 1;
|
success += 1;
|
||||||
did = true;
|
did = true;
|
||||||
} else {
|
} else {
|
||||||
pattern = 'HTTP/1.1 '
|
pattern = 'HTTP/1.1 ';
|
||||||
if ((d.length === pattern.length && d === pattern) ||
|
if ((d.length === pattern.length && d === pattern) ||
|
||||||
(d.length > pattern.length &&
|
(d.length > pattern.length &&
|
||||||
d.slice(0, pattern.length) === pattern)) {
|
d.slice(0, pattern.length) === pattern)) {
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var common = require('../common.js');
|
var common = require('../common.js');
|
||||||
var PORT = common.PORT;
|
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
var bench = common.createBenchmark(main, {
|
||||||
num: [1, 4, 8, 16],
|
num: [1, 4, 8, 16],
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var common = require('../common.js');
|
var common = require('../common.js');
|
||||||
var PORT = common.PORT;
|
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
var bench = common.createBenchmark(main, {
|
||||||
type: ['asc', 'utf', 'buf'],
|
type: ['asc', 'utf', 'buf'],
|
||||||
|
@ -4,8 +4,8 @@ var path = require('path');
|
|||||||
var http = require('http');
|
var http = require('http');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var spawn = require('child_process').spawn;
|
var spawn = require('child_process').spawn;
|
||||||
var common = require('../common.js')
|
require('../common.js');
|
||||||
var test = require('../../test/common.js')
|
var test = require('../../test/common.js');
|
||||||
var pep = path.dirname(process.argv[1]) + '/_chunky_http_client.js';
|
var pep = path.dirname(process.argv[1]) + '/_chunky_http_client.js';
|
||||||
var PIPE = test.PIPE;
|
var PIPE = test.PIPE;
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@ var bench = common.createBenchmark(main, {
|
|||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
process.env.PORT = PORT;
|
process.env.PORT = PORT;
|
||||||
var spawn = require('child_process').spawn;
|
|
||||||
var server = require('../http_simple.js');
|
var server = require('../http_simple.js');
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
var path = '/' + conf.type + '/' + conf.length + '/' + conf.chunks;
|
var path = '/' + conf.type + '/' + conf.length + '/' + conf.chunks;
|
||||||
|
@ -8,7 +8,7 @@ http.createServer(function(req, res) {
|
|||||||
res.writeHead(200, { 'content-type': 'text/plain',
|
res.writeHead(200, { 'content-type': 'text/plain',
|
||||||
'content-length': '2' });
|
'content-length': '2' });
|
||||||
|
|
||||||
var lag = parseInt(req.url.split("/").pop(), 10) || defaultLag;
|
var lag = parseInt(req.url.split('/').pop(), 10) || defaultLag;
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
res.end('ok');
|
res.end('ok');
|
||||||
}, lag);
|
}, lag);
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var path = require('path'),
|
var http = require('http');
|
||||||
exec = require('child_process').exec,
|
|
||||||
http = require('http');
|
|
||||||
|
|
||||||
var port = parseInt(process.env.PORT || 8000);
|
var port = parseInt(process.env.PORT || 8000);
|
||||||
|
|
||||||
@ -41,7 +39,7 @@ var server = module.exports = http.createServer(function (req, res) {
|
|||||||
if (command == 'bytes') {
|
if (command == 'bytes') {
|
||||||
var n = ~~arg;
|
var n = ~~arg;
|
||||||
if (n <= 0)
|
if (n <= 0)
|
||||||
throw new Error('bytes called with n <= 0')
|
throw new Error('bytes called with n <= 0');
|
||||||
if (storedBytes[n] === undefined) {
|
if (storedBytes[n] === undefined) {
|
||||||
storedBytes[n] = makeString(n, 'C');
|
storedBytes[n] = makeString(n, 'C');
|
||||||
}
|
}
|
||||||
|
@ -8,74 +8,73 @@
|
|||||||
//
|
//
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var path = require("path");
|
var http = require('http');
|
||||||
var http = require("http");
|
var spawn = require('child_process').spawn;
|
||||||
var spawn = require("child_process").spawn;
|
|
||||||
|
|
||||||
var port = parseInt(process.env.PORT || 8000);
|
var port = parseInt(process.env.PORT || 8000);
|
||||||
|
|
||||||
var fixed = ""
|
var fixed = '';
|
||||||
for (var i = 0; i < 20 * 1024; i++) {
|
for (var i = 0; i < 20 * 1024; i++) {
|
||||||
fixed += "C";
|
fixed += 'C';
|
||||||
}
|
}
|
||||||
|
|
||||||
var stored = {};
|
var stored = {};
|
||||||
var storedBuffer = {};
|
var storedBuffer = {};
|
||||||
|
|
||||||
var server = http.createServer(function(req, res) {
|
var server = http.createServer(function(req, res) {
|
||||||
var commands = req.url.split("/");
|
var commands = req.url.split('/');
|
||||||
var command = commands[1];
|
var command = commands[1];
|
||||||
var body = "";
|
var body = '';
|
||||||
var arg = commands[2];
|
var arg = commands[2];
|
||||||
var n_chunks = parseInt(commands[3], 10);
|
var n_chunks = parseInt(commands[3], 10);
|
||||||
var status = 200;
|
var status = 200;
|
||||||
|
|
||||||
if (command == "bytes") {
|
if (command == 'bytes') {
|
||||||
var n = parseInt(arg, 10)
|
var n = parseInt(arg, 10);
|
||||||
if (n <= 0)
|
if (n <= 0)
|
||||||
throw "bytes called with n <= 0"
|
throw new Error('bytes called with n <= 0');
|
||||||
if (stored[n] === undefined) {
|
if (stored[n] === undefined) {
|
||||||
stored[n] = "";
|
stored[n] = '';
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
stored[n] += "C"
|
stored[n] += 'C';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
body = stored[n];
|
body = stored[n];
|
||||||
|
|
||||||
} else if (command == "buffer") {
|
} else if (command == 'buffer') {
|
||||||
var n = parseInt(arg, 10)
|
var n = parseInt(arg, 10);
|
||||||
if (n <= 0) throw new Error("bytes called with n <= 0");
|
if (n <= 0) throw new Error('bytes called with n <= 0');
|
||||||
if (storedBuffer[n] === undefined) {
|
if (storedBuffer[n] === undefined) {
|
||||||
storedBuffer[n] = new Buffer(n);
|
storedBuffer[n] = new Buffer(n);
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
storedBuffer[n][i] = "C".charCodeAt(0);
|
storedBuffer[n][i] = 'C'.charCodeAt(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
body = storedBuffer[n];
|
body = storedBuffer[n];
|
||||||
|
|
||||||
} else if (command == "quit") {
|
} else if (command == 'quit') {
|
||||||
res.connection.server.close();
|
res.connection.server.close();
|
||||||
body = "quitting";
|
body = 'quitting';
|
||||||
|
|
||||||
} else if (command == "fixed") {
|
} else if (command == 'fixed') {
|
||||||
body = fixed;
|
body = fixed;
|
||||||
|
|
||||||
} else if (command == "echo") {
|
} else if (command == 'echo') {
|
||||||
res.writeHead(200, { "Content-Type": "text/plain",
|
res.writeHead(200, { 'Content-Type': 'text/plain',
|
||||||
"Transfer-Encoding": "chunked" });
|
'Transfer-Encoding': 'chunked' });
|
||||||
req.pipe(res);
|
req.pipe(res);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
status = 404;
|
status = 404;
|
||||||
body = "not found\n";
|
body = 'not found\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
// example: http://localhost:port/bytes/512/4
|
// example: http://localhost:port/bytes/512/4
|
||||||
// sends a 512 byte body in 4 chunks of 128 bytes
|
// sends a 512 byte body in 4 chunks of 128 bytes
|
||||||
if (n_chunks > 0) {
|
if (n_chunks > 0) {
|
||||||
res.writeHead(status, { "Content-Type": "text/plain",
|
res.writeHead(status, { 'Content-Type': 'text/plain',
|
||||||
"Transfer-Encoding": "chunked" });
|
'Transfer-Encoding': 'chunked' });
|
||||||
// send body in chunks
|
// send body in chunks
|
||||||
var len = body.length;
|
var len = body.length;
|
||||||
var step = Math.floor(len / n_chunks) || 1;
|
var step = Math.floor(len / n_chunks) || 1;
|
||||||
@ -87,8 +86,8 @@ var server = http.createServer(function (req, res) {
|
|||||||
} else {
|
} else {
|
||||||
var content_length = body.length.toString();
|
var content_length = body.length.toString();
|
||||||
|
|
||||||
res.writeHead(status, { "Content-Type": "text/plain",
|
res.writeHead(status, { 'Content-Type': 'text/plain',
|
||||||
"Content-Length": content_length });
|
'Content-Length': content_length });
|
||||||
res.end(body);
|
res.end(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,8 +3,6 @@ const net = require('net');
|
|||||||
|
|
||||||
var errors = 0, connections = 0;
|
var errors = 0, connections = 0;
|
||||||
|
|
||||||
var lastClose = 0;
|
|
||||||
|
|
||||||
function connect() {
|
function connect() {
|
||||||
process.nextTick(function() {
|
process.nextTick(function() {
|
||||||
var s = net.Stream();
|
var s = net.Stream();
|
||||||
@ -39,12 +37,12 @@ setInterval(connect, 5000);
|
|||||||
setInterval(function() {
|
setInterval(function() {
|
||||||
if (oldConnections != connections) {
|
if (oldConnections != connections) {
|
||||||
oldConnections = connections;
|
oldConnections = connections;
|
||||||
console.log("CLIENT %d connections: %d", process.pid, connections);
|
console.log('CLIENT %d connections: %d', process.pid, connections);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldErrors != errors) {
|
if (oldErrors != errors) {
|
||||||
oldErrors = errors;
|
oldErrors = errors;
|
||||||
console.log("CLIENT %d errors: %d", process.pid, errors);
|
console.log('CLIENT %d errors: %d', process.pid, errors);
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
var connections = 0;
|
|
||||||
var errors = 0;
|
var errors = 0;
|
||||||
|
|
||||||
var server = net.Server(function(socket) {
|
var server = net.Server(function(socket) {
|
||||||
@ -21,11 +20,11 @@ var oldConnections, oldErrors;
|
|||||||
setInterval(function() {
|
setInterval(function() {
|
||||||
if (oldConnections != server.connections) {
|
if (oldConnections != server.connections) {
|
||||||
oldConnections = server.connections;
|
oldConnections = server.connections;
|
||||||
console.log("SERVER %d connections: %d", process.pid, server.connections);
|
console.log('SERVER %d connections: %d', process.pid, server.connections);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldErrors != errors) {
|
if (oldErrors != errors) {
|
||||||
oldErrors = errors;
|
oldErrors = errors;
|
||||||
console.log("SERVER %d errors: %d", process.pid, errors);
|
console.log('SERVER %d errors: %d', process.pid, errors);
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
@ -3,9 +3,6 @@ var common = require('../common.js');
|
|||||||
var spawn = require('child_process').spawn;
|
var spawn = require('child_process').spawn;
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var emptyJsFile = path.resolve(__dirname, '../../test/fixtures/semicolon.js');
|
var emptyJsFile = path.resolve(__dirname, '../../test/fixtures/semicolon.js');
|
||||||
var starts = 100;
|
|
||||||
var i = 0;
|
|
||||||
var start;
|
|
||||||
|
|
||||||
var bench = common.createBenchmark(startNode, {
|
var bench = common.createBenchmark(startNode, {
|
||||||
dur: [1]
|
dur: [1]
|
||||||
@ -15,7 +12,6 @@ function startNode(conf) {
|
|||||||
var dur = +conf.dur;
|
var dur = +conf.dur;
|
||||||
var go = true;
|
var go = true;
|
||||||
var starts = 0;
|
var starts = 0;
|
||||||
var open = 0;
|
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
go = false;
|
go = false;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
var common = require('../common.js');
|
var common = require('../common.js');
|
||||||
var bench = common.createBenchmark(main, {
|
var bench = common.createBenchmark(main, {
|
||||||
millions: [100]
|
millions: [100]
|
||||||
})
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = +conf.millions * 1e6;
|
var n = +conf.millions * 1e6;
|
||||||
@ -11,7 +11,7 @@ function main(conf) {
|
|||||||
var s;
|
var s;
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
s = '01234567890';
|
s = '01234567890';
|
||||||
s[1] = "a";
|
s[1] = 'a';
|
||||||
}
|
}
|
||||||
bench.end(n / 1e6);
|
bench.end(n / 1e6);
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var common = require('../common.js');
|
var common = require('../common.js');
|
||||||
var packageJson = '{"main": "index.js"}';
|
|
||||||
|
|
||||||
var tmpDirectory = path.join(__dirname, '..', 'tmp');
|
var tmpDirectory = path.join(__dirname, '..', 'tmp');
|
||||||
var benchmarkDirectory = path.join(tmpDirectory, 'nodejs-benchmark-module');
|
var benchmarkDirectory = path.join(tmpDirectory, 'nodejs-benchmark-module');
|
||||||
|
@ -36,7 +36,6 @@ function main(conf) {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error('invalid type: ' + type);
|
throw new Error('invalid type: ' + type);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
server();
|
server();
|
||||||
@ -78,8 +77,8 @@ function server() {
|
|||||||
socket.on('connect', function() {
|
socket.on('connect', function() {
|
||||||
bench.start();
|
bench.start();
|
||||||
|
|
||||||
socket.on('drain', send)
|
socket.on('drain', send);
|
||||||
send()
|
send();
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
var bytes = writer.received;
|
var bytes = writer.received;
|
||||||
|
@ -36,7 +36,6 @@ function main(conf) {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error('invalid type: ' + type);
|
throw new Error('invalid type: ' + type);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
server();
|
server();
|
||||||
|
@ -36,7 +36,6 @@ function main(conf) {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error('invalid type: ' + type);
|
throw new Error('invalid type: ' + type);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
server();
|
server();
|
||||||
|
@ -36,7 +36,6 @@ function main(conf) {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error('invalid type: ' + type);
|
throw new Error('invalid type: ' + type);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
server();
|
server();
|
||||||
|
@ -90,7 +90,6 @@ function client() {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error('invalid type: ' + type);
|
throw new Error('invalid type: ' + type);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var clientHandle = new TCP();
|
var clientHandle = new TCP();
|
||||||
|
@ -88,7 +88,6 @@ function client() {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error('invalid type: ' + type);
|
throw new Error('invalid type: ' + type);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var clientHandle = new TCP();
|
var clientHandle = new TCP();
|
||||||
|
@ -62,7 +62,6 @@ function server() {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error('invalid type: ' + type);
|
throw new Error('invalid type: ' + type);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
clientHandle.readStart();
|
clientHandle.readStart();
|
||||||
|
@ -20,7 +20,7 @@ var server = http.createServer(function(req, res) {
|
|||||||
'Content-Length': body.length
|
'Content-Length': body.length
|
||||||
});
|
});
|
||||||
res.end(body);
|
res.end(body);
|
||||||
})
|
});
|
||||||
|
|
||||||
server.listen(port, function() {
|
server.listen(port, function() {
|
||||||
var agent = new http.Agent();
|
var agent = new http.Agent();
|
||||||
|
@ -54,7 +54,6 @@ function main(conf) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function write() {
|
function write() {
|
||||||
var i = 0;
|
|
||||||
while (false !== conn.write(chunk, encoding));
|
while (false !== conn.write(chunk, encoding));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var assert = require('assert'),
|
var fs = require('fs'),
|
||||||
fs = require('fs'),
|
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
tls = require('tls');
|
tls = require('tls');
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ function main(conf) {
|
|||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i += 1) {
|
for (var i = 0; i < n; i += 1) {
|
||||||
var r = util.inspect({a: 'a', b: 'b', c: 'c', d: 'd'});
|
util.inspect({a: 'a', b: 'b', c: 'c', d: 'd'});
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user