benchmark: refactor for consistent style
Code in benchmark directory sometimes uses `function () {}` for anonymous callbacks and sometimes uses `() => {}`. Multi-line arrays sometimes have a trailing comma and sometimes do not. Update to always use arrow functions for anonymous callbacks and trailing commas for multiline arrays. PR-URL: https://github.com/nodejs/node/pull/25944 Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
d310d8df62
commit
29e74d4952
@ -6,10 +6,8 @@ const path = require('path');
|
|||||||
// Create an object of all benchmark scripts
|
// Create an object of all benchmark scripts
|
||||||
const benchmarks = {};
|
const benchmarks = {};
|
||||||
fs.readdirSync(__dirname)
|
fs.readdirSync(__dirname)
|
||||||
.filter(function(name) {
|
.filter((name) => fs.statSync(path.resolve(__dirname, name)).isDirectory())
|
||||||
return fs.statSync(path.resolve(__dirname, name)).isDirectory();
|
.forEach((category) => {
|
||||||
})
|
|
||||||
.forEach(function(category) {
|
|
||||||
benchmarks[category] = fs.readdirSync(path.resolve(__dirname, category))
|
benchmarks[category] = fs.readdirSync(path.resolve(__dirname, category))
|
||||||
.filter((filename) => filename[0] !== '.' && filename[0] !== '_');
|
.filter((filename) => filename[0] !== '.' && filename[0] !== '_');
|
||||||
});
|
});
|
||||||
|
@ -12,7 +12,7 @@ const chars = [
|
|||||||
'hello brendan!!!', // 1 byte
|
'hello brendan!!!', // 1 byte
|
||||||
'ΰαβγδεζηθικλμνξο', // 2 bytes
|
'ΰαβγδεζηθικλμνξο', // 2 bytes
|
||||||
'挰挱挲挳挴挵挶挷挸挹挺挻挼挽挾挿', // 3 bytes
|
'挰挱挲挳挴挵挶挷挸挹挺挻挼挽挾挿', // 3 bytes
|
||||||
'𠜎𠜱𠝹𠱓𠱸𠲖𠳏𠳕𠴕𠵼𠵿𠸎𠸏𠹷𠺝𠺢' // 4 bytes
|
'𠜎𠜱𠝹𠱓𠱸𠲖𠳏𠳕𠴕𠵼𠵿𠸎𠸏𠹷𠺝𠺢', // 4 bytes
|
||||||
];
|
];
|
||||||
|
|
||||||
function main({ n, len, encoding }) {
|
function main({ n, len, encoding }) {
|
||||||
@ -33,9 +33,7 @@ function main({ n, len, encoding }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check the result to ensure it is *properly* optimized
|
// Check the result to ensure it is *properly* optimized
|
||||||
results = strings.map(function(val) {
|
results = strings.map((val) => Buffer.byteLength(val, encoding));
|
||||||
return Buffer.byteLength(val, encoding);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
|
@ -12,7 +12,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
'fill("t", "utf8")',
|
'fill("t", "utf8")',
|
||||||
'fill("t", 0, "utf8")',
|
'fill("t", 0, "utf8")',
|
||||||
'fill("t", 0)',
|
'fill("t", 0)',
|
||||||
'fill(Buffer.alloc(1), 0)'
|
'fill(Buffer.alloc(1), 0)',
|
||||||
],
|
],
|
||||||
size: [2 ** 8, 2 ** 13, 2 ** 16],
|
size: [2 ** 8, 2 ** 13, 2 ** 16],
|
||||||
n: [2e4]
|
n: [2e4]
|
||||||
|
@ -12,7 +12,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
'string',
|
'string',
|
||||||
'string-utf8',
|
'string-utf8',
|
||||||
'string-base64',
|
'string-base64',
|
||||||
'object'
|
'object',
|
||||||
],
|
],
|
||||||
len: [10, 2048],
|
len: [10, 2048],
|
||||||
n: [2048]
|
n: [2048]
|
||||||
|
@ -18,7 +18,7 @@ const searchStrings = [
|
|||||||
'Soo--oop',
|
'Soo--oop',
|
||||||
'aaaaaaaaaaaaaaaaa',
|
'aaaaaaaaaaaaaaaaa',
|
||||||
'venture to go near the house till she had brought herself down to',
|
'venture to go near the house till she had brought herself down to',
|
||||||
'</i> to the Caterpillar'
|
'</i> to the Caterpillar',
|
||||||
];
|
];
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
|
@ -25,7 +25,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
'utf16le',
|
'utf16le',
|
||||||
'UTF16LE',
|
'UTF16LE',
|
||||||
'utf8',
|
'utf8',
|
||||||
'UTF8'
|
'UTF8',
|
||||||
],
|
],
|
||||||
n: [1e6]
|
n: [1e6]
|
||||||
}, {
|
}, {
|
||||||
|
@ -5,7 +5,7 @@ const types = [
|
|||||||
'IntBE',
|
'IntBE',
|
||||||
'IntLE',
|
'IntLE',
|
||||||
'UIntBE',
|
'UIntBE',
|
||||||
'UIntLE'
|
'UIntLE',
|
||||||
];
|
];
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
|
@ -15,7 +15,7 @@ const types = [
|
|||||||
'FloatLE',
|
'FloatLE',
|
||||||
'FloatBE',
|
'FloatBE',
|
||||||
'DoubleLE',
|
'DoubleLE',
|
||||||
'DoubleBE'
|
'DoubleBE',
|
||||||
];
|
];
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
const common = require('../common.js');
|
const common = require('../common.js');
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
encoding: [
|
encoding: [
|
||||||
'', 'utf8', 'ascii', 'hex', 'UCS-2', 'utf16le', 'latin1', 'binary'
|
'', 'utf8', 'ascii', 'hex', 'UCS-2', 'utf16le', 'latin1', 'binary',
|
||||||
],
|
],
|
||||||
args: [ '', 'offset', 'offset+length' ],
|
args: [ '', 'offset', 'offset+length' ],
|
||||||
len: [10, 2048],
|
len: [10, 2048],
|
||||||
|
@ -19,7 +19,7 @@ const types = [
|
|||||||
'FloatLE',
|
'FloatLE',
|
||||||
'FloatBE',
|
'FloatBE',
|
||||||
'DoubleLE',
|
'DoubleLE',
|
||||||
'DoubleBE'
|
'DoubleBE',
|
||||||
];
|
];
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
|
@ -15,7 +15,7 @@ const types = [
|
|||||||
'Float32LE',
|
'Float32LE',
|
||||||
'Float32BE',
|
'Float32BE',
|
||||||
'Float64LE',
|
'Float64LE',
|
||||||
'Float64BE'
|
'Float64BE',
|
||||||
];
|
];
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
|
@ -13,7 +13,7 @@ if (process.argv[2] === 'child') {
|
|||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
len: [
|
len: [
|
||||||
64, 256, 1024, 4096, 16384, 65536,
|
64, 256, 1024, 4096, 16384, 65536,
|
||||||
65536 << 4, 65536 << 8
|
65536 << 4, 65536 << 8,
|
||||||
],
|
],
|
||||||
dur: [5]
|
dur: [5]
|
||||||
});
|
});
|
||||||
@ -27,11 +27,9 @@ if (process.argv[2] === 'child') {
|
|||||||
[process.argv[1], 'child', len], options);
|
[process.argv[1], 'child', len], options);
|
||||||
|
|
||||||
var bytes = 0;
|
var bytes = 0;
|
||||||
child.on('message', function(msg) {
|
child.on('message', (msg) => { bytes += msg.length; });
|
||||||
bytes += msg.length;
|
|
||||||
});
|
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(() => {
|
||||||
child.kill();
|
child.kill();
|
||||||
bench.end(bytes);
|
bench.end(bytes);
|
||||||
}, dur * 1000);
|
}, dur * 1000);
|
||||||
|
@ -25,11 +25,11 @@ function main({ dur, len }) {
|
|||||||
const child = child_process.spawn('yes', [msg], options);
|
const child = child_process.spawn('yes', [msg], options);
|
||||||
|
|
||||||
var bytes = 0;
|
var bytes = 0;
|
||||||
child.stdout.on('data', function(msg) {
|
child.stdout.on('data', (msg) => {
|
||||||
bytes += msg.length;
|
bytes += msg.length;
|
||||||
});
|
});
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(() => {
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
// Sometimes there's a yes.exe process left hanging around on Windows...
|
// Sometimes there's a yes.exe process left hanging around on Windows...
|
||||||
child_process.execSync(`taskkill /f /t /pid ${child.pid}`);
|
child_process.execSync(`taskkill /f /t /pid ${child.pid}`);
|
||||||
|
@ -15,7 +15,7 @@ function go(n, left) {
|
|||||||
return bench.end(n);
|
return bench.end(n);
|
||||||
|
|
||||||
const child = spawn('echo', ['hello']);
|
const child = spawn('echo', ['hello']);
|
||||||
child.on('exit', function(code) {
|
child.on('exit', (code) => {
|
||||||
if (code)
|
if (code)
|
||||||
process.exit(code);
|
process.exit(code);
|
||||||
else
|
else
|
||||||
|
@ -61,7 +61,7 @@ if (cluster.isMaster) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
process.on('message', function(msg) {
|
process.on('message', (msg) => {
|
||||||
process.send(msg);
|
process.send(msg);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ if (showProgress) {
|
|||||||
execPath: cli.optional[job.binary]
|
execPath: cli.optional[job.binary]
|
||||||
});
|
});
|
||||||
|
|
||||||
child.on('message', function(data) {
|
child.on('message', (data) => {
|
||||||
if (data.type === 'report') {
|
if (data.type === 'report') {
|
||||||
// Construct configuration string, " A=a, B=b, ..."
|
// Construct configuration string, " A=a, B=b, ..."
|
||||||
let conf = '';
|
let conf = '';
|
||||||
@ -95,7 +95,7 @@ if (showProgress) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
child.once('close', function(code) {
|
child.once('close', (code) => {
|
||||||
if (code) {
|
if (code) {
|
||||||
process.exit(code);
|
process.exit(code);
|
||||||
return;
|
return;
|
||||||
|
@ -66,11 +66,11 @@ function main({ api, cipher, type, len, writes }) {
|
|||||||
|
|
||||||
function streamWrite(alice, bob, message, encoding, writes) {
|
function streamWrite(alice, bob, message, encoding, writes) {
|
||||||
var written = 0;
|
var written = 0;
|
||||||
bob.on('data', function(c) {
|
bob.on('data', (c) => {
|
||||||
written += c.length;
|
written += c.length;
|
||||||
});
|
});
|
||||||
|
|
||||||
bob.on('end', function() {
|
bob.on('end', () => {
|
||||||
// Gbits
|
// Gbits
|
||||||
const bits = written * 8;
|
const bits = written * 8;
|
||||||
const gbits = bits / (1024 * 1024 * 1024);
|
const gbits = bits / (1024 * 1024 * 1024);
|
||||||
|
@ -9,7 +9,7 @@ const keylen_list = ['1024', '2048', '4096'];
|
|||||||
const RSA_PublicPem = {};
|
const RSA_PublicPem = {};
|
||||||
const RSA_PrivatePem = {};
|
const RSA_PrivatePem = {};
|
||||||
|
|
||||||
keylen_list.forEach(function(key) {
|
keylen_list.forEach((key) => {
|
||||||
RSA_PublicPem[key] =
|
RSA_PublicPem[key] =
|
||||||
fs.readFileSync(`${fixtures_keydir}/rsa_public_${key}.pem`);
|
fs.readFileSync(`${fixtures_keydir}/rsa_public_${key}.pem`);
|
||||||
RSA_PrivatePem[key] =
|
RSA_PrivatePem[key] =
|
||||||
|
@ -9,7 +9,7 @@ const keylen_list = ['1024', '2048'];
|
|||||||
const RSA_PublicPem = {};
|
const RSA_PublicPem = {};
|
||||||
const RSA_PrivatePem = {};
|
const RSA_PrivatePem = {};
|
||||||
|
|
||||||
keylen_list.forEach(function(key) {
|
keylen_list.forEach((key) => {
|
||||||
RSA_PublicPem[key] =
|
RSA_PublicPem[key] =
|
||||||
fs.readFileSync(`${fixtures_keydir}/rsa_public_${key}.pem`);
|
fs.readFileSync(`${fixtures_keydir}/rsa_public_${key}.pem`);
|
||||||
RSA_PrivatePem[key] =
|
RSA_PrivatePem[key] =
|
||||||
|
@ -43,11 +43,11 @@ function main({ dur, len, num, type, chunks }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.on('listening', function() {
|
socket.on('listening', () => {
|
||||||
bench.start();
|
bench.start();
|
||||||
onsend();
|
onsend();
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(() => {
|
||||||
const bytes = sent * len;
|
const bytes = sent * len;
|
||||||
const gbits = (bytes * 8) / (1024 * 1024 * 1024);
|
const gbits = (bytes * 8) / (1024 * 1024 * 1024);
|
||||||
bench.end(gbits);
|
bench.end(gbits);
|
||||||
|
@ -33,11 +33,11 @@ function main({ dur, len, num, type, chunks }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.on('listening', function() {
|
socket.on('listening', () => {
|
||||||
bench.start();
|
bench.start();
|
||||||
onsend();
|
onsend();
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(() => {
|
||||||
const bytes = (type === 'send' ? sent : received) * len;
|
const bytes = (type === 'send' ? sent : received) * len;
|
||||||
const gbits = (bytes * 8) / (1024 * 1024 * 1024);
|
const gbits = (bytes * 8) / (1024 * 1024 * 1024);
|
||||||
bench.end(gbits);
|
bench.end(gbits);
|
||||||
@ -45,7 +45,7 @@ function main({ dur, len, num, type, chunks }) {
|
|||||||
}, dur * 1000);
|
}, dur * 1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('message', function() {
|
socket.on('message', () => {
|
||||||
received++;
|
received++;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -29,11 +29,11 @@ function main({ dur, len, num, type }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.on('listening', function() {
|
socket.on('listening', () => {
|
||||||
bench.start();
|
bench.start();
|
||||||
onsend();
|
onsend();
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(() => {
|
||||||
const bytes = (type === 'send' ? sent : received) * chunk.length;
|
const bytes = (type === 'send' ? sent : received) * chunk.length;
|
||||||
const gbits = (bytes * 8) / (1024 * 1024 * 1024);
|
const gbits = (bytes * 8) / (1024 * 1024 * 1024);
|
||||||
bench.end(gbits);
|
bench.end(gbits);
|
||||||
@ -41,7 +41,7 @@ function main({ dur, len, num, type }) {
|
|||||||
}, dur * 1000);
|
}, dur * 1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('message', function() {
|
socket.on('message', () => {
|
||||||
received++;
|
received++;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -29,11 +29,11 @@ function main({ dur, len, num, type }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.on('listening', function() {
|
socket.on('listening', () => {
|
||||||
bench.start();
|
bench.start();
|
||||||
onsend();
|
onsend();
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(() => {
|
||||||
const bytes = (type === 'send' ? sent : received) * chunk.length;
|
const bytes = (type === 'send' ? sent : received) * chunk.length;
|
||||||
const gbits = (bytes * 8) / (1024 * 1024 * 1024);
|
const gbits = (bytes * 8) / (1024 * 1024 * 1024);
|
||||||
bench.end(gbits);
|
bench.end(gbits);
|
||||||
@ -41,7 +41,7 @@ function main({ dur, len, num, type }) {
|
|||||||
}, dur * 1000);
|
}, dur * 1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('message', function() {
|
socket.on('message', () => {
|
||||||
received++;
|
received++;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ const assert = require('assert');
|
|||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
method: [
|
method: [
|
||||||
'object', 'nullProtoObject', 'nullProtoLiteralObject', 'storageObject',
|
'object', 'nullProtoObject', 'nullProtoLiteralObject', 'storageObject',
|
||||||
'fakeMap', 'map'
|
'fakeMap', 'map',
|
||||||
],
|
],
|
||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
@ -10,7 +10,7 @@ function main({ n }) {
|
|||||||
|
|
||||||
var k;
|
var k;
|
||||||
for (k = 0; k < 10; k += 1)
|
for (k = 0; k < 10; k += 1)
|
||||||
listeners.push(function() {});
|
listeners.push(() => {});
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i += 1) {
|
for (var i = 0; i < n; i += 1) {
|
||||||
|
@ -12,7 +12,7 @@ function main({ n, argc, listeners }) {
|
|||||||
const ee = new EventEmitter();
|
const ee = new EventEmitter();
|
||||||
|
|
||||||
for (var k = 0; k < listeners; k += 1)
|
for (var k = 0; k < listeners; k += 1)
|
||||||
ee.on('dummy', function() {});
|
ee.on('dummy', () => {});
|
||||||
|
|
||||||
var i;
|
var i;
|
||||||
switch (argc) {
|
switch (argc) {
|
||||||
|
@ -8,8 +8,8 @@ function main({ n }) {
|
|||||||
const ee = new EventEmitter();
|
const ee = new EventEmitter();
|
||||||
|
|
||||||
for (var k = 0; k < 5; k += 1) {
|
for (var k = 0; k < 5; k += 1) {
|
||||||
ee.on('dummy0', function() {});
|
ee.on('dummy0', () => {});
|
||||||
ee.on('dummy1', function() {});
|
ee.on('dummy1', () => {});
|
||||||
}
|
}
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
|
@ -9,8 +9,8 @@ function main({ n }) {
|
|||||||
ee.setMaxListeners(101);
|
ee.setMaxListeners(101);
|
||||||
|
|
||||||
for (var k = 0; k < 50; k += 1) {
|
for (var k = 0; k < 50; k += 1) {
|
||||||
ee.on('dummy0', function() {});
|
ee.on('dummy0', () => {});
|
||||||
ee.on('dummy1', function() {});
|
ee.on('dummy1', () => {});
|
||||||
}
|
}
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
|
@ -8,8 +8,8 @@ function main({ n }) {
|
|||||||
const ee = new EventEmitter();
|
const ee = new EventEmitter();
|
||||||
|
|
||||||
for (var k = 0; k < 5; k += 1) {
|
for (var k = 0; k < 5; k += 1) {
|
||||||
ee.on('dummy0', function() {});
|
ee.on('dummy0', () => {});
|
||||||
ee.on('dummy1', function() {});
|
ee.on('dummy1', () => {});
|
||||||
}
|
}
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
|
@ -13,14 +13,14 @@ const useDomains = process.env.NODE_USE_DOMAINS;
|
|||||||
if (useDomains) {
|
if (useDomains) {
|
||||||
var domain = require('domain');
|
var domain = require('domain');
|
||||||
const gdom = domain.create();
|
const gdom = domain.create();
|
||||||
gdom.on('error', function(er) {
|
gdom.on('error', (er) => {
|
||||||
console.error('Error on global domain', er);
|
console.error('Error on global domain', er);
|
||||||
throw er;
|
throw er;
|
||||||
});
|
});
|
||||||
gdom.enter();
|
gdom.enter();
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = http.createServer(function(req, res) {
|
module.exports = http.createServer((req, res) => {
|
||||||
if (useDomains) {
|
if (useDomains) {
|
||||||
const dom = domain.create();
|
const dom = domain.create();
|
||||||
dom.add(req);
|
dom.add(req);
|
||||||
|
@ -17,7 +17,7 @@ function main({ n, dir, withFileTypes }) {
|
|||||||
(function r(cntr) {
|
(function r(cntr) {
|
||||||
if (cntr-- <= 0)
|
if (cntr-- <= 0)
|
||||||
return bench.end(n);
|
return bench.end(n);
|
||||||
fs.readdir(fullPath, { withFileTypes }, function() {
|
fs.readdir(fullPath, { withFileTypes }, () => {
|
||||||
r(cntr);
|
r(cntr);
|
||||||
});
|
});
|
||||||
}(n));
|
}(n));
|
||||||
|
@ -24,7 +24,7 @@ function relativePath(n) {
|
|||||||
(function r(cntr) {
|
(function r(cntr) {
|
||||||
if (cntr-- <= 0)
|
if (cntr-- <= 0)
|
||||||
return bench.end(n);
|
return bench.end(n);
|
||||||
fs.realpath(relative_path, function() {
|
fs.realpath(relative_path, () => {
|
||||||
r(cntr);
|
r(cntr);
|
||||||
});
|
});
|
||||||
}(n));
|
}(n));
|
||||||
@ -34,7 +34,7 @@ function resolvedPath(n) {
|
|||||||
(function r(cntr) {
|
(function r(cntr) {
|
||||||
if (cntr-- <= 0)
|
if (cntr-- <= 0)
|
||||||
return bench.end(n);
|
return bench.end(n);
|
||||||
fs.realpath(resolved_path, function() {
|
fs.realpath(resolved_path, () => {
|
||||||
r(cntr);
|
r(cntr);
|
||||||
});
|
});
|
||||||
}(n));
|
}(n));
|
||||||
|
@ -24,7 +24,7 @@ function main({ n, statType }) {
|
|||||||
fs.closeSync(arg);
|
fs.closeSync(arg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fn(arg, function() {
|
fn(arg, () => {
|
||||||
r(cntr, fn);
|
r(cntr, fn);
|
||||||
});
|
});
|
||||||
}(n, fs[statType]));
|
}(n, fs[statType]));
|
||||||
|
@ -45,16 +45,16 @@ function runTest() {
|
|||||||
encoding: encoding
|
encoding: encoding
|
||||||
});
|
});
|
||||||
|
|
||||||
rs.on('open', function() {
|
rs.on('open', () => {
|
||||||
bench.start();
|
bench.start();
|
||||||
});
|
});
|
||||||
|
|
||||||
var bytes = 0;
|
var bytes = 0;
|
||||||
rs.on('data', function(chunk) {
|
rs.on('data', (chunk) => {
|
||||||
bytes += chunk.length;
|
bytes += chunk.length;
|
||||||
});
|
});
|
||||||
|
|
||||||
rs.on('end', function() {
|
rs.on('end', () => {
|
||||||
try { fs.unlinkSync(filename); } catch {}
|
try { fs.unlinkSync(filename); } catch {}
|
||||||
// MB/sec
|
// MB/sec
|
||||||
bench.end(bytes / (1024 * 1024));
|
bench.end(bytes / (1024 * 1024));
|
||||||
|
@ -35,7 +35,7 @@ function main(conf) {
|
|||||||
var zips = 0;
|
var zips = 0;
|
||||||
var benchEnded = false;
|
var benchEnded = false;
|
||||||
bench.start();
|
bench.start();
|
||||||
setTimeout(function() {
|
setTimeout(() => {
|
||||||
const totalOps = reads + zips;
|
const totalOps = reads + zips;
|
||||||
benchEnded = true;
|
benchEnded = true;
|
||||||
bench.end(totalOps);
|
bench.end(totalOps);
|
||||||
|
@ -25,7 +25,7 @@ function main({ len, dur, concurrent }) {
|
|||||||
var reads = 0;
|
var reads = 0;
|
||||||
var benchEnded = false;
|
var benchEnded = false;
|
||||||
bench.start();
|
bench.start();
|
||||||
setTimeout(function() {
|
setTimeout(() => {
|
||||||
benchEnded = true;
|
benchEnded = true;
|
||||||
bench.end(reads);
|
bench.end(reads);
|
||||||
try { fs.unlinkSync(filename); } catch {}
|
try { fs.unlinkSync(filename); } catch {}
|
||||||
|
@ -42,7 +42,7 @@ function main({ dur, encodingType, size }) {
|
|||||||
f.on('drain', write);
|
f.on('drain', write);
|
||||||
f.on('open', write);
|
f.on('open', write);
|
||||||
f.on('close', done);
|
f.on('close', done);
|
||||||
f.on('finish', function() {
|
f.on('finish', () => {
|
||||||
ended = true;
|
ended = true;
|
||||||
const written = fs.statSync(filename).size / 1024;
|
const written = fs.statSync(filename).size / 1024;
|
||||||
try { fs.unlinkSync(filename); } catch {}
|
try { fs.unlinkSync(filename); } catch {}
|
||||||
@ -53,7 +53,7 @@ function main({ dur, encodingType, size }) {
|
|||||||
function write() {
|
function write() {
|
||||||
if (!started) {
|
if (!started) {
|
||||||
started = true;
|
started = true;
|
||||||
setTimeout(function() {
|
setTimeout(() => {
|
||||||
f.end();
|
f.end();
|
||||||
}, dur * 1000);
|
}, dur * 1000);
|
||||||
bench.start();
|
bench.start();
|
||||||
|
@ -54,11 +54,11 @@ function main({ len, n }) {
|
|||||||
const add = 11;
|
const add = 11;
|
||||||
var count = 0;
|
var count = 0;
|
||||||
const PIPE = process.env.PIPE_NAME;
|
const PIPE = process.env.PIPE_NAME;
|
||||||
var socket = net.connect(PIPE, function() {
|
var socket = net.connect(PIPE, () => {
|
||||||
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', (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';
|
||||||
if ((d.length === pattern.length && d === pattern) ||
|
if ((d.length === pattern.length && d === pattern) ||
|
||||||
@ -84,11 +84,11 @@ function main({ len, n }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
socket.on('close', function() {
|
socket.on('close', () => {
|
||||||
console.log('Connection closed');
|
console.log('Connection closed');
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('error', function() {
|
socket.on('error', () => {
|
||||||
throw new Error('Connection error');
|
throw new Error('Connection error');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -18,7 +18,7 @@ const groupedInputs = {
|
|||||||
'sessionid=; Path=/', 'text/html; charset=utf-8',
|
'sessionid=; Path=/', 'text/html; charset=utf-8',
|
||||||
'text/html; charset=utf-8', '10', 'W/"a-eda64de5"', 'OK', 'Express',
|
'text/html; charset=utf-8', '10', 'W/"a-eda64de5"', 'OK', 'Express',
|
||||||
'Express', 'X-HTTP-Method-Override', 'sessionid=; Path=/',
|
'Express', 'X-HTTP-Method-Override', 'sessionid=; Path=/',
|
||||||
'application/json'
|
'application/json',
|
||||||
],
|
],
|
||||||
|
|
||||||
// Put it here so the benchmark result lines will not be super long.
|
// Put it here so the benchmark result lines will not be super long.
|
||||||
@ -45,7 +45,7 @@ const inputs = [
|
|||||||
// Invalid
|
// Invalid
|
||||||
'中文呢', // unicode
|
'中文呢', // unicode
|
||||||
'foo\nbar',
|
'foo\nbar',
|
||||||
'\x7F'
|
'\x7F',
|
||||||
];
|
];
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
|
@ -35,7 +35,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
'中文呢', // unicode
|
'中文呢', // unicode
|
||||||
'((((())))', // invalid
|
'((((())))', // invalid
|
||||||
':alternate-protocol', // fast bailout
|
':alternate-protocol', // fast bailout
|
||||||
'alternate-protocol:' // slow bailout
|
'alternate-protocol:', // slow bailout
|
||||||
],
|
],
|
||||||
n: [1e6],
|
n: [1e6],
|
||||||
});
|
});
|
||||||
|
@ -20,21 +20,21 @@ function main({ len, n, c }) {
|
|||||||
const http = require('http');
|
const http = require('http');
|
||||||
const chunk = Buffer.alloc(len, '8');
|
const chunk = Buffer.alloc(len, '8');
|
||||||
|
|
||||||
const server = http.createServer(function(req, res) {
|
const server = http.createServer((req, res) => {
|
||||||
function send(left) {
|
function send(left) {
|
||||||
if (left === 0) return res.end();
|
if (left === 0) return res.end();
|
||||||
res.write(chunk);
|
res.write(chunk);
|
||||||
setTimeout(function() {
|
setTimeout(() => {
|
||||||
send(left - 1);
|
send(left - 1);
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
send(n);
|
send(n);
|
||||||
});
|
});
|
||||||
|
|
||||||
server.listen(common.PORT, function() {
|
server.listen(common.PORT, () => {
|
||||||
bench.http({
|
bench.http({
|
||||||
connections: c
|
connections: c
|
||||||
}, function() {
|
}, () => {
|
||||||
server.close();
|
server.close();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -37,17 +37,17 @@ function main({ dur, len, type, method }) {
|
|||||||
method: 'POST'
|
method: 'POST'
|
||||||
};
|
};
|
||||||
|
|
||||||
const server = http.createServer(function(req, res) {
|
const server = http.createServer((req, res) => {
|
||||||
res.end();
|
res.end();
|
||||||
});
|
});
|
||||||
server.listen(options.port, options.host, function() {
|
server.listen(options.port, options.host, () => {
|
||||||
setTimeout(done, dur * 1000);
|
setTimeout(done, dur * 1000);
|
||||||
bench.start();
|
bench.start();
|
||||||
pummel();
|
pummel();
|
||||||
});
|
});
|
||||||
|
|
||||||
function pummel() {
|
function pummel() {
|
||||||
const req = http.request(options, function(res) {
|
const req = http.request(options, (res) => {
|
||||||
nreqs++;
|
nreqs++;
|
||||||
pummel(); // Line up next request.
|
pummel(); // Line up next request.
|
||||||
res.resume();
|
res.resume();
|
||||||
|
@ -21,18 +21,18 @@ function main({ type, len, c }) {
|
|||||||
const w1 = cluster.fork();
|
const w1 = cluster.fork();
|
||||||
const w2 = cluster.fork();
|
const w2 = cluster.fork();
|
||||||
|
|
||||||
cluster.on('listening', function() {
|
cluster.on('listening', () => {
|
||||||
workers++;
|
workers++;
|
||||||
if (workers < 2)
|
if (workers < 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
setImmediate(function() {
|
setImmediate(() => {
|
||||||
const path = `/${type}/${len}`;
|
const path = `/${type}/${len}`;
|
||||||
|
|
||||||
bench.http({
|
bench.http({
|
||||||
path: path,
|
path: path,
|
||||||
connections: c
|
connections: c
|
||||||
}, function() {
|
}, () => {
|
||||||
w1.destroy();
|
w1.destroy();
|
||||||
w2.destroy();
|
w2.destroy();
|
||||||
});
|
});
|
||||||
|
@ -43,14 +43,14 @@ function main({ len, type, method, c }) {
|
|||||||
|
|
||||||
const fn = method === 'write' ? write : end;
|
const fn = method === 'write' ? write : end;
|
||||||
|
|
||||||
const server = http.createServer(function(req, res) {
|
const server = http.createServer((req, res) => {
|
||||||
fn(res);
|
fn(res);
|
||||||
});
|
});
|
||||||
|
|
||||||
server.listen(common.PORT, function() {
|
server.listen(common.PORT, () => {
|
||||||
bench.http({
|
bench.http({
|
||||||
connections: c
|
connections: c
|
||||||
}, function() {
|
}, () => {
|
||||||
server.close();
|
server.close();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -21,15 +21,15 @@ function main({ duplicates, n }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const server = http.createServer(function(req, res) {
|
const server = http.createServer((req, res) => {
|
||||||
res.writeHead(200, headers);
|
res.writeHead(200, headers);
|
||||||
res.end();
|
res.end();
|
||||||
});
|
});
|
||||||
server.listen(common.PORT, function() {
|
server.listen(common.PORT, () => {
|
||||||
bench.http({
|
bench.http({
|
||||||
path: '/',
|
path: '/',
|
||||||
connections: 10
|
connections: 10
|
||||||
}, function() {
|
}, () => {
|
||||||
server.close();
|
server.close();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -12,7 +12,7 @@ tmpdir.refresh();
|
|||||||
|
|
||||||
var server;
|
var server;
|
||||||
|
|
||||||
server = http.createServer(function(req, res) {
|
server = http.createServer((req, res) => {
|
||||||
const headers = {
|
const headers = {
|
||||||
'content-type': 'text/plain',
|
'content-type': 'text/plain',
|
||||||
'content-length': '2'
|
'content-length': '2'
|
||||||
@ -21,7 +21,7 @@ server = http.createServer(function(req, res) {
|
|||||||
res.end('ok');
|
res.end('ok');
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on('error', function(err) {
|
server.on('error', (err) => {
|
||||||
throw new Error(`server error: ${err}`);
|
throw new Error(`server error: ${err}`);
|
||||||
});
|
});
|
||||||
server.listen(PIPE);
|
server.listen(PIPE);
|
||||||
@ -31,7 +31,7 @@ const child = fork(
|
|||||||
process.argv.slice(2)
|
process.argv.slice(2)
|
||||||
);
|
);
|
||||||
child.on('message', common.sendResult);
|
child.on('message', common.sendResult);
|
||||||
child.on('close', function(code) {
|
child.on('close', (code) => {
|
||||||
server.close();
|
server.close();
|
||||||
assert.strictEqual(code, 0);
|
assert.strictEqual(code, 0);
|
||||||
});
|
});
|
||||||
|
@ -19,13 +19,13 @@ function main({ res }) {
|
|||||||
process.env.PORT = PORT;
|
process.env.PORT = PORT;
|
||||||
var server = require('../fixtures/simple-http-server.js')
|
var server = require('../fixtures/simple-http-server.js')
|
||||||
.listen(PORT)
|
.listen(PORT)
|
||||||
.on('listening', function() {
|
.on('listening', () => {
|
||||||
const path = `/${type}/${len}/${chunks}/normal/${chunkedEnc}`;
|
const path = `/${type}/${len}/${chunks}/normal/${chunkedEnc}`;
|
||||||
|
|
||||||
bench.http({
|
bench.http({
|
||||||
path: path,
|
path: path,
|
||||||
connections: c
|
connections: c
|
||||||
}, function() {
|
}, () => {
|
||||||
server.close();
|
server.close();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -11,7 +11,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
'Content-Type',
|
'Content-Type',
|
||||||
'Content-Length',
|
'Content-Length',
|
||||||
'Connection',
|
'Connection',
|
||||||
'Transfer-Encoding'
|
'Transfer-Encoding',
|
||||||
],
|
],
|
||||||
n: [1e6],
|
n: [1e6],
|
||||||
});
|
});
|
||||||
|
@ -13,13 +13,13 @@ const bench = common.createBenchmark(main, {
|
|||||||
function main({ type, len, chunks, c, chunkedEnc, res }) {
|
function main({ type, len, chunks, c, chunkedEnc, res }) {
|
||||||
var server = require('../fixtures/simple-http-server.js')
|
var server = require('../fixtures/simple-http-server.js')
|
||||||
.listen(common.PORT)
|
.listen(common.PORT)
|
||||||
.on('listening', function() {
|
.on('listening', () => {
|
||||||
const path = `/${type}/${len}/${chunks}/normal/${chunkedEnc}`;
|
const path = `/${type}/${len}/${chunks}/normal/${chunkedEnc}`;
|
||||||
|
|
||||||
bench.http({
|
bench.http({
|
||||||
path: path,
|
path: path,
|
||||||
connections: c
|
connections: c
|
||||||
}, function() {
|
}, () => {
|
||||||
server.close();
|
server.close();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -21,14 +21,14 @@ const resData = 'HTTP/1.1 101 Web Socket Protocol Handshake\r\n' +
|
|||||||
function main({ n }) {
|
function main({ n }) {
|
||||||
var server = require('../fixtures/simple-http-server.js')
|
var server = require('../fixtures/simple-http-server.js')
|
||||||
.listen(common.PORT)
|
.listen(common.PORT)
|
||||||
.on('listening', function() {
|
.on('listening', () => {
|
||||||
bench.start();
|
bench.start();
|
||||||
doBench(server.address(), n, function() {
|
doBench(server.address(), n, () => {
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
server.close();
|
server.close();
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.on('upgrade', function(req, socket, upgradeHead) {
|
.on('upgrade', (req, socket, upgradeHead) => {
|
||||||
socket.resume();
|
socket.resume();
|
||||||
socket.write(resData);
|
socket.write(resData);
|
||||||
socket.end();
|
socket.end();
|
||||||
@ -45,7 +45,7 @@ function doBench(address, count, done) {
|
|||||||
conn.write(reqData);
|
conn.write(reqData);
|
||||||
conn.resume();
|
conn.resume();
|
||||||
|
|
||||||
conn.on('end', function() {
|
conn.on('end', () => {
|
||||||
doBench(address, count - 1, done);
|
doBench(address, count - 1, done);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ const methods = [
|
|||||||
'restAndSpread',
|
'restAndSpread',
|
||||||
'argumentsAndApply',
|
'argumentsAndApply',
|
||||||
'restAndApply',
|
'restAndApply',
|
||||||
'predefined'
|
'predefined',
|
||||||
];
|
];
|
||||||
|
|
||||||
const bench = createBenchmark(main, {
|
const bench = createBenchmark(main, {
|
||||||
|
@ -32,7 +32,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
'éire.icom.museum',
|
'éire.icom.museum',
|
||||||
'איקו״ם.ישראל.museum',
|
'איקו״ם.ישראל.museum',
|
||||||
'日本.icom.museum',
|
'日本.icom.museum',
|
||||||
'الأردن.icom.museum'
|
'الأردن.icom.museum',
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ function main({ dur, script, mode }) {
|
|||||||
throughput: 0
|
throughput: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(() => {
|
||||||
state.go = false;
|
state.go = false;
|
||||||
}, dur * 1000);
|
}, dur * 1000);
|
||||||
|
|
||||||
|
@ -34,19 +34,19 @@ function main({ dur, len, type }) {
|
|||||||
const writer = new Writer();
|
const writer = new Writer();
|
||||||
|
|
||||||
// the actual benchmark.
|
// the actual benchmark.
|
||||||
const server = net.createServer(function(socket) {
|
const server = net.createServer((socket) => {
|
||||||
socket.pipe(writer);
|
socket.pipe(writer);
|
||||||
});
|
});
|
||||||
|
|
||||||
server.listen(PORT, function() {
|
server.listen(PORT, () => {
|
||||||
const socket = net.connect(PORT);
|
const socket = net.connect(PORT);
|
||||||
socket.on('connect', function() {
|
socket.on('connect', () => {
|
||||||
bench.start();
|
bench.start();
|
||||||
|
|
||||||
socket.on('drain', send);
|
socket.on('drain', send);
|
||||||
send();
|
send();
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(() => {
|
||||||
const bytes = writer.received;
|
const bytes = writer.received;
|
||||||
const gbits = (bytes * 8) / (1024 * 1024 * 1024);
|
const gbits = (bytes * 8) / (1024 * 1024 * 1024);
|
||||||
bench.end(gbits);
|
bench.end(gbits);
|
||||||
|
@ -35,18 +35,18 @@ function main({ dur, len, type }) {
|
|||||||
const writer = new Writer();
|
const writer = new Writer();
|
||||||
|
|
||||||
// the actual benchmark.
|
// the actual benchmark.
|
||||||
const server = net.createServer(function(socket) {
|
const server = net.createServer((socket) => {
|
||||||
socket.pipe(writer);
|
socket.pipe(writer);
|
||||||
});
|
});
|
||||||
|
|
||||||
server.listen(PORT, function() {
|
server.listen(PORT, () => {
|
||||||
const socket = net.connect(PORT);
|
const socket = net.connect(PORT);
|
||||||
socket.on('connect', function() {
|
socket.on('connect', () => {
|
||||||
bench.start();
|
bench.start();
|
||||||
|
|
||||||
reader.pipe(socket);
|
reader.pipe(socket);
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(() => {
|
||||||
const bytes = writer.received;
|
const bytes = writer.received;
|
||||||
const gbits = (bytes * 8) / (1024 * 1024 * 1024);
|
const gbits = (bytes * 8) / (1024 * 1024 * 1024);
|
||||||
bench.end(gbits);
|
bench.end(gbits);
|
||||||
|
@ -35,19 +35,19 @@ function main({ dur, len, type }) {
|
|||||||
const writer = new Writer();
|
const writer = new Writer();
|
||||||
|
|
||||||
// the actual benchmark.
|
// the actual benchmark.
|
||||||
const server = net.createServer(function(socket) {
|
const server = net.createServer((socket) => {
|
||||||
socket.pipe(socket);
|
socket.pipe(socket);
|
||||||
});
|
});
|
||||||
|
|
||||||
server.listen(PORT, function() {
|
server.listen(PORT, () => {
|
||||||
const socket = net.connect(PORT);
|
const socket = net.connect(PORT);
|
||||||
socket.on('connect', function() {
|
socket.on('connect', () => {
|
||||||
bench.start();
|
bench.start();
|
||||||
|
|
||||||
reader.pipe(socket);
|
reader.pipe(socket);
|
||||||
socket.pipe(writer);
|
socket.pipe(writer);
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(() => {
|
||||||
// Multiply by 2 since we're sending it first one way
|
// Multiply by 2 since we're sending it first one way
|
||||||
// then then back again.
|
// then then back again.
|
||||||
const bytes = writer.received * 2;
|
const bytes = writer.received * 2;
|
||||||
|
@ -34,18 +34,18 @@ function main({ dur, len, type }) {
|
|||||||
const writer = new Writer();
|
const writer = new Writer();
|
||||||
|
|
||||||
// the actual benchmark.
|
// the actual benchmark.
|
||||||
const server = net.createServer(function(socket) {
|
const server = net.createServer((socket) => {
|
||||||
reader.pipe(socket);
|
reader.pipe(socket);
|
||||||
});
|
});
|
||||||
|
|
||||||
server.listen(PORT, function() {
|
server.listen(PORT, () => {
|
||||||
const socket = net.connect(PORT);
|
const socket = net.connect(PORT);
|
||||||
socket.on('connect', function() {
|
socket.on('connect', () => {
|
||||||
bench.start();
|
bench.start();
|
||||||
|
|
||||||
socket.pipe(writer);
|
socket.pipe(writer);
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(() => {
|
||||||
const bytes = writer.received;
|
const bytes = writer.received;
|
||||||
const gbits = (bytes * 8) / (1024 * 1024 * 1024);
|
const gbits = (bytes * 8) / (1024 * 1024 * 1024);
|
||||||
bench.end(gbits);
|
bench.end(gbits);
|
||||||
|
@ -44,7 +44,7 @@ function main({ dur, len, type }) {
|
|||||||
reader.pipe(fakeSocket);
|
reader.pipe(fakeSocket);
|
||||||
fakeSocket.pipe(writer);
|
fakeSocket.pipe(writer);
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(() => {
|
||||||
const bytes = writer.received;
|
const bytes = writer.received;
|
||||||
const gbits = (bytes * 8) / (1024 * 1024 * 1024);
|
const gbits = (bytes * 8) / (1024 * 1024 * 1024);
|
||||||
bench.end(gbits);
|
bench.end(gbits);
|
||||||
|
@ -40,7 +40,7 @@ function main({ dur, len, type }) {
|
|||||||
bench.start();
|
bench.start();
|
||||||
var bytes = 0;
|
var bytes = 0;
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(() => {
|
||||||
// report in Gb/sec
|
// report in Gb/sec
|
||||||
bench.end((bytes * 8) / (1024 * 1024 * 1024));
|
bench.end((bytes * 8) / (1024 * 1024 * 1024));
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
|
@ -104,7 +104,7 @@ function main({ dur, len, type }) {
|
|||||||
|
|
||||||
clientHandle.readStart();
|
clientHandle.readStart();
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(() => {
|
||||||
// Multiply by 2 since we're sending it first one way
|
// Multiply by 2 since we're sending it first one way
|
||||||
// then then back again.
|
// then then back again.
|
||||||
bench.end(2 * (bytes * 8) / (1024 * 1024 * 1024));
|
bench.end(2 * (bytes * 8) / (1024 * 1024 * 1024));
|
||||||
|
@ -78,7 +78,7 @@ function main({ dur, len, type }) {
|
|||||||
if (err) {
|
if (err) {
|
||||||
fail(err, 'write');
|
fail(err, 'write');
|
||||||
} else if (!writeReq.async) {
|
} else if (!writeReq.async) {
|
||||||
process.nextTick(function() {
|
process.nextTick(() => {
|
||||||
afterWrite(0, clientHandle);
|
afterWrite(0, clientHandle);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -125,7 +125,7 @@ function main({ dur, len, type }) {
|
|||||||
// the meat of the benchmark is right here:
|
// the meat of the benchmark is right here:
|
||||||
bench.start();
|
bench.start();
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(() => {
|
||||||
// report in Gb/sec
|
// report in Gb/sec
|
||||||
bench.end((bytes * 8) / (1024 * 1024 * 1024));
|
bench.end((bytes * 8) / (1024 * 1024 * 1024));
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
|
@ -13,7 +13,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
'foo/bar.',
|
'foo/bar.',
|
||||||
['foo/bar.', '.'].join('|'),
|
['foo/bar.', '.'].join('|'),
|
||||||
'/foo/bar/baz/asdf/quux.html',
|
'/foo/bar/baz/asdf/quux.html',
|
||||||
['/foo/bar/baz/asdf/quux.html', '.html'].join('|')
|
['/foo/bar/baz/asdf/quux.html', '.html'].join('|'),
|
||||||
],
|
],
|
||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
@ -13,7 +13,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
'foo\\bar.',
|
'foo\\bar.',
|
||||||
['foo\\bar.', '.'].join('|'),
|
['foo\\bar.', '.'].join('|'),
|
||||||
'\\foo\\bar\\baz\\asdf\\quux.html',
|
'\\foo\\bar\\baz\\asdf\\quux.html',
|
||||||
['\\foo\\bar\\baz\\asdf\\quux.html', '.html'].join('|')
|
['\\foo\\bar\\baz\\asdf\\quux.html', '.html'].join('|'),
|
||||||
],
|
],
|
||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
@ -10,7 +10,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
'/foo/bar',
|
'/foo/bar',
|
||||||
'foo',
|
'foo',
|
||||||
'foo/bar',
|
'foo/bar',
|
||||||
'/foo/bar/baz/asdf/quux'
|
'/foo/bar/baz/asdf/quux',
|
||||||
],
|
],
|
||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
@ -10,7 +10,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
'C:\\foo\\bar',
|
'C:\\foo\\bar',
|
||||||
'foo',
|
'foo',
|
||||||
'foo\\bar',
|
'foo\\bar',
|
||||||
'D:\\foo\\bar\\baz\\asdf\\quux'
|
'D:\\foo\\bar\\baz\\asdf\\quux',
|
||||||
],
|
],
|
||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
@ -13,7 +13,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
'foo/bar/..baz.quux',
|
'foo/bar/..baz.quux',
|
||||||
'foo/bar/...baz.quux',
|
'foo/bar/...baz.quux',
|
||||||
'/foo/bar/baz/asdf/quux',
|
'/foo/bar/baz/asdf/quux',
|
||||||
'/foo/bar/baz/asdf/quux.foobarbazasdfquux'
|
'/foo/bar/baz/asdf/quux.foobarbazasdfquux',
|
||||||
],
|
],
|
||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
@ -13,7 +13,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
'foo\\bar\\..baz.quux',
|
'foo\\bar\\..baz.quux',
|
||||||
'foo\\bar\\...baz.quux',
|
'foo\\bar\\...baz.quux',
|
||||||
'D:\\foo\\bar\\baz\\asdf\\quux',
|
'D:\\foo\\bar\\baz\\asdf\\quux',
|
||||||
'\\foo\\bar\\baz\\asdf\\quux.foobarbazasdfquux'
|
'\\foo\\bar\\baz\\asdf\\quux.foobarbazasdfquux',
|
||||||
],
|
],
|
||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
@ -4,7 +4,7 @@ const { posix } = require('path');
|
|||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
props: [
|
props: [
|
||||||
['/', '/home/user/dir', 'index.html', '.html', 'index'].join('|')
|
['/', '/home/user/dir', 'index.html', '.html', 'index'].join('|'),
|
||||||
],
|
],
|
||||||
n: [1e7]
|
n: [1e7]
|
||||||
});
|
});
|
||||||
|
@ -4,7 +4,7 @@ const { win32 } = require('path');
|
|||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
props: [
|
props: [
|
||||||
['C:\\', 'C:\\path\\dir', 'index.html', '.html', 'index'].join('|')
|
['C:\\', 'C:\\path\\dir', 'index.html', '.html', 'index'].join('|'),
|
||||||
],
|
],
|
||||||
n: [1e7]
|
n: [1e7]
|
||||||
});
|
});
|
||||||
|
@ -8,7 +8,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
'.',
|
'.',
|
||||||
'/foo/bar',
|
'/foo/bar',
|
||||||
'/baz/..',
|
'/baz/..',
|
||||||
'bar/baz'
|
'bar/baz',
|
||||||
],
|
],
|
||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
@ -9,7 +9,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
'//server',
|
'//server',
|
||||||
'C:\\baz\\..',
|
'C:\\baz\\..',
|
||||||
'C:baz\\..',
|
'C:baz\\..',
|
||||||
'bar\\baz'
|
'bar\\baz',
|
||||||
],
|
],
|
||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
@ -4,7 +4,7 @@ const { posix } = require('path');
|
|||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
paths: [
|
paths: [
|
||||||
['/foo', 'bar', '', 'baz/asdf', 'quux', '..'].join('|')
|
['/foo', 'bar', '', 'baz/asdf', 'quux', '..'].join('|'),
|
||||||
],
|
],
|
||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
@ -4,7 +4,7 @@ const { win32 } = require('path');
|
|||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
paths: [
|
paths: [
|
||||||
['C:\\foo', 'bar', '', 'baz\\asdf', 'quux', '..'].join('|')
|
['C:\\foo', 'bar', '', 'baz\\asdf', 'quux', '..'].join('|'),
|
||||||
],
|
],
|
||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
@ -7,7 +7,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
'foo\\bar',
|
'foo\\bar',
|
||||||
'C:\\foo',
|
'C:\\foo',
|
||||||
'\\\\foo\\bar',
|
'\\\\foo\\bar',
|
||||||
'\\\\?\\foo'
|
'\\\\?\\foo',
|
||||||
],
|
],
|
||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
@ -9,7 +9,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
'/../',
|
'/../',
|
||||||
'/foo',
|
'/foo',
|
||||||
'/foo/bar',
|
'/foo/bar',
|
||||||
'/foo/bar//baz/asdf/quux/..'
|
'/foo/bar//baz/asdf/quux/..',
|
||||||
],
|
],
|
||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
@ -9,7 +9,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
'C:\\..\\',
|
'C:\\..\\',
|
||||||
'C:\\foo',
|
'C:\\foo',
|
||||||
'C:\\foo\\bar',
|
'C:\\foo\\bar',
|
||||||
'C:\\foo\\bar\\\\baz\\asdf\\quux\\..'
|
'C:\\foo\\bar\\\\baz\\asdf\\quux\\..',
|
||||||
],
|
],
|
||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
@ -10,7 +10,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
'/foo/bar.baz',
|
'/foo/bar.baz',
|
||||||
'foo/.bar.baz',
|
'foo/.bar.baz',
|
||||||
'foo/bar',
|
'foo/bar',
|
||||||
'/foo/bar/baz/asdf/.quux'
|
'/foo/bar/baz/asdf/.quux',
|
||||||
],
|
],
|
||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
@ -11,7 +11,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
'E:\\foo\\bar.baz',
|
'E:\\foo\\bar.baz',
|
||||||
'foo\\.bar.baz',
|
'foo\\.bar.baz',
|
||||||
'foo\\bar',
|
'foo\\bar',
|
||||||
'\\foo\\bar\\baz\\asdf\\.quux'
|
'\\foo\\bar\\baz\\asdf\\.quux',
|
||||||
],
|
],
|
||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
@ -10,7 +10,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
['/var', '/bin'].join('|'),
|
['/var', '/bin'].join('|'),
|
||||||
['/foo/bar/baz/quux', '/'].join('|'),
|
['/foo/bar/baz/quux', '/'].join('|'),
|
||||||
['/foo/bar/baz/quux', '/foo/bar/baz/quux'].join('|'),
|
['/foo/bar/baz/quux', '/foo/bar/baz/quux'].join('|'),
|
||||||
['/foo/bar/baz/quux', '/var/log'].join('|')
|
['/foo/bar/baz/quux', '/var/log'].join('|'),
|
||||||
],
|
],
|
||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
@ -8,7 +8,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
['C:\\', 'D:\\'].join('|'),
|
['C:\\', 'D:\\'].join('|'),
|
||||||
['C:\\foo\\bar\\baz', 'C:\\foo\\bar\\baz'].join('|'),
|
['C:\\foo\\bar\\baz', 'C:\\foo\\bar\\baz'].join('|'),
|
||||||
['C:\\foo\\BAR\\BAZ', 'C:\\foo\\bar\\baz'].join('|'),
|
['C:\\foo\\BAR\\BAZ', 'C:\\foo\\bar\\baz'].join('|'),
|
||||||
['C:\\foo\\bar\\baz\\quux', 'C:\\'].join('|')
|
['C:\\foo\\bar\\baz\\quux', 'C:\\'].join('|'),
|
||||||
],
|
],
|
||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
@ -7,7 +7,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
'',
|
'',
|
||||||
['', ''].join('|'),
|
['', ''].join('|'),
|
||||||
['foo/bar', '/tmp/file/', '..', 'a/../subfile'].join('|'),
|
['foo/bar', '/tmp/file/', '..', 'a/../subfile'].join('|'),
|
||||||
['a/b/c/', '../../..'].join('|')
|
['a/b/c/', '../../..'].join('|'),
|
||||||
],
|
],
|
||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
@ -7,7 +7,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
'',
|
'',
|
||||||
['', ''].join('|'),
|
['', ''].join('|'),
|
||||||
['c:/ignore', 'd:\\a/b\\c/d', '\\e.exe'].join('|'),
|
['c:/ignore', 'd:\\a/b\\c/d', '\\e.exe'].join('|'),
|
||||||
['c:/blah\\blah', 'd:/games', 'c:../a'].join('|')
|
['c:/blah\\blah', 'd:/games', 'c:../a'].join('|'),
|
||||||
],
|
],
|
||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
@ -7,7 +7,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
'there is nothing to unescape here',
|
'there is nothing to unescape here',
|
||||||
'there%20are%20several%20spaces%20that%20need%20to%20be%20unescaped',
|
'there%20are%20several%20spaces%20that%20need%20to%20be%20unescaped',
|
||||||
'there%2Qare%0-fake%escaped values in%%%%this%9Hstring',
|
'there%2Qare%0-fake%escaped values in%%%%this%9Hstring',
|
||||||
'%20%21%22%23%24%25%26%27%28%29%2A%2B%2C%2D%2E%2F%30%31%32%33%34%35%36%37'
|
'%20%21%22%23%24%25%26%27%28%29%2A%2B%2C%2D%2E%2F%30%31%32%33%34%35%36%37',
|
||||||
],
|
],
|
||||||
n: [10e6],
|
n: [10e6],
|
||||||
});
|
});
|
||||||
|
@ -41,7 +41,7 @@ if (format === 'csv') {
|
|||||||
console.log(filename);
|
console.log(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
child.on('message', function(data) {
|
child.on('message', (data) => {
|
||||||
if (data.type !== 'report') {
|
if (data.type !== 'report') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ if (format === 'csv') {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
child.once('close', function(code) {
|
child.once('close', (code) => {
|
||||||
if (code) {
|
if (code) {
|
||||||
process.exit(code);
|
process.exit(code);
|
||||||
return;
|
return;
|
||||||
|
@ -39,7 +39,7 @@ function csvEncodeValue(value) {
|
|||||||
(function recursive(i) {
|
(function recursive(i) {
|
||||||
const child = fork(path.resolve(__dirname, filepath), cli.optional.set);
|
const child = fork(path.resolve(__dirname, filepath), cli.optional.set);
|
||||||
|
|
||||||
child.on('message', function(data) {
|
child.on('message', (data) => {
|
||||||
if (data.type !== 'report') {
|
if (data.type !== 'report') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -61,7 +61,7 @@ function csvEncodeValue(value) {
|
|||||||
console.log(`"${name}", ${confData}, ${data.rate}, ${data.time}`);
|
console.log(`"${name}", ${confData}, ${data.rate}, ${data.time}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
child.once('close', function(code) {
|
child.once('close', (code) => {
|
||||||
if (code) {
|
if (code) {
|
||||||
process.exit(code);
|
process.exit(code);
|
||||||
return;
|
return;
|
||||||
|
@ -4,7 +4,7 @@ const StringDecoder = require('string_decoder').StringDecoder;
|
|||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
encoding: [
|
encoding: [
|
||||||
'ascii', 'utf8', 'utf-8', 'base64', 'ucs2', 'UTF-8', 'AscII', 'UTF-16LE'
|
'ascii', 'utf8', 'utf-8', 'base64', 'ucs2', 'UTF-8', 'AscII', 'UTF-16LE',
|
||||||
],
|
],
|
||||||
n: [25e6]
|
n: [25e6]
|
||||||
});
|
});
|
||||||
|
@ -54,7 +54,7 @@ function main({ encoding, inLen, chunkLen, n }) {
|
|||||||
}
|
}
|
||||||
str = Buffer.concat([
|
str = Buffer.concat([
|
||||||
str,
|
str,
|
||||||
buf.slice(start % buf.length, end % buf.length)
|
buf.slice(start % buf.length, end % buf.length),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
|
|
||||||
function main({ n }) {
|
function main({ n }) {
|
||||||
|
|
||||||
process.on('exit', function() {
|
process.on('exit', () => {
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
|
|
||||||
function main({ n }) {
|
function main({ n }) {
|
||||||
|
|
||||||
process.on('exit', function() {
|
process.on('exit', () => {
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
|
|
||||||
function main({ n }) {
|
function main({ n }) {
|
||||||
|
|
||||||
process.on('exit', function() {
|
process.on('exit', () => {
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -41,9 +41,9 @@ function main({ dur, type, size }) {
|
|||||||
|
|
||||||
server = tls.createServer(options, onConnection);
|
server = tls.createServer(options, onConnection);
|
||||||
var conn;
|
var conn;
|
||||||
server.listen(common.PORT, function() {
|
server.listen(common.PORT, () => {
|
||||||
const opt = { port: common.PORT, rejectUnauthorized: false };
|
const opt = { port: common.PORT, rejectUnauthorized: false };
|
||||||
conn = tls.connect(opt, function() {
|
conn = tls.connect(opt, () => {
|
||||||
setTimeout(done, dur * 1000);
|
setTimeout(done, dur * 1000);
|
||||||
bench.start();
|
bench.start();
|
||||||
conn.on('drain', write);
|
conn.on('drain', write);
|
||||||
@ -57,7 +57,7 @@ function main({ dur, type, size }) {
|
|||||||
|
|
||||||
var received = 0;
|
var received = 0;
|
||||||
function onConnection(conn) {
|
function onConnection(conn) {
|
||||||
conn.on('data', function(chunk) {
|
conn.on('data', (chunk) => {
|
||||||
received += chunk.length;
|
received += chunk.length;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -46,9 +46,9 @@ function makeConnection() {
|
|||||||
port: common.PORT,
|
port: common.PORT,
|
||||||
rejectUnauthorized: false
|
rejectUnauthorized: false
|
||||||
};
|
};
|
||||||
var conn = tls.connect(options, function() {
|
var conn = tls.connect(options, () => {
|
||||||
clientConn++;
|
clientConn++;
|
||||||
conn.on('error', function(er) {
|
conn.on('error', (er) => {
|
||||||
console.error('client error', er);
|
console.error('client error', er);
|
||||||
throw er;
|
throw er;
|
||||||
});
|
});
|
||||||
|
@ -23,7 +23,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
'Array',
|
'Array',
|
||||||
'TypedArray',
|
'TypedArray',
|
||||||
'TypedArray_extra',
|
'TypedArray_extra',
|
||||||
'Number'
|
'Number',
|
||||||
],
|
],
|
||||||
option: Object.keys(opts)
|
option: Object.keys(opts)
|
||||||
});
|
});
|
||||||
|
@ -16,7 +16,7 @@ const inputs = [
|
|||||||
'', 'utf8', 'utf-8', 'UTF-8', 'UTF8', 'Utf8',
|
'', 'utf8', 'utf-8', 'UTF-8', 'UTF8', 'Utf8',
|
||||||
'ucs2', 'UCS2', 'utf16le', 'UTF16LE',
|
'ucs2', 'UCS2', 'utf16le', 'UTF16LE',
|
||||||
'binary', 'BINARY', 'latin1', 'base64', 'BASE64',
|
'binary', 'BINARY', 'latin1', 'base64', 'BASE64',
|
||||||
'hex', 'HEX', 'foo', 'undefined'
|
'hex', 'HEX', 'foo', 'undefined',
|
||||||
];
|
];
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
|
@ -6,7 +6,7 @@ const v8 = require('v8');
|
|||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
method: [
|
method: [
|
||||||
'getHeapStatistics',
|
'getHeapStatistics',
|
||||||
'getHeapSpaceStatistics'
|
'getHeapSpaceStatistics',
|
||||||
],
|
],
|
||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
@ -5,7 +5,7 @@ const zlib = require('zlib');
|
|||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
type: [
|
type: [
|
||||||
'Deflate', 'DeflateRaw', 'Inflate', 'InflateRaw', 'Gzip', 'Gunzip', 'Unzip',
|
'Deflate', 'DeflateRaw', 'Inflate', 'InflateRaw', 'Gzip', 'Gunzip', 'Unzip',
|
||||||
'BrotliCompress', 'BrotliDecompress'
|
'BrotliCompress', 'BrotliDecompress',
|
||||||
],
|
],
|
||||||
options: ['true', 'false'],
|
options: ['true', 'false'],
|
||||||
n: [5e5]
|
n: [5e5]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user