benchmark: var to const
PR-URL: https://github.com/nodejs/node/pull/13757 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
This commit is contained in:
parent
b1c8f15c5f
commit
e167ab71fb
@ -3,8 +3,8 @@
|
|||||||
const readline = require('readline');
|
const readline = require('readline');
|
||||||
|
|
||||||
function pad(input, minLength, fill) {
|
function pad(input, minLength, fill) {
|
||||||
var result = String(input);
|
const result = String(input);
|
||||||
var padding = fill.repeat(Math.max(0, minLength - result.length));
|
const padding = fill.repeat(Math.max(0, minLength - result.length));
|
||||||
return `${padding}${result}`;
|
return `${padding}${result}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ function main(conf) {
|
|||||||
const n = +conf.n;
|
const n = +conf.n;
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
var arr = new clazz(n * 1e6);
|
const arr = new clazz(n * 1e6);
|
||||||
for (var i = 0; i < 10; ++i) {
|
for (var i = 0; i < 10; ++i) {
|
||||||
run();
|
run();
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ function main(conf) {
|
|||||||
const n = +conf.n;
|
const n = +conf.n;
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
var arr = new clazz(n * 1e6);
|
const arr = new clazz(n * 1e6);
|
||||||
for (var i = 0; i < 10; ++i) {
|
for (var i = 0; i < 10; ++i) {
|
||||||
run();
|
run();
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ function main(conf) {
|
|||||||
const n = +conf.n;
|
const n = +conf.n;
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
var arr = new clazz(n * 1e6);
|
const arr = new clazz(n * 1e6);
|
||||||
for (var i = 0; i < 10; ++i) {
|
for (var i = 0; i < 10; ++i) {
|
||||||
run();
|
run();
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
len: [64 * 1024 * 1024],
|
len: [64 * 1024 * 1024],
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common');
|
const common = require('../common');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
encoding: ['utf8', 'base64', 'buffer'],
|
encoding: ['utf8', 'base64', 'buffer'],
|
||||||
len: [1, 2, 4, 16, 64, 256], // x16
|
len: [1, 2, 4, 16, 64, 256], // x16
|
||||||
n: [5e6]
|
n: [5e6]
|
||||||
});
|
});
|
||||||
|
|
||||||
// 16 chars each
|
// 16 chars each
|
||||||
var chars = [
|
const chars = [
|
||||||
'hello brendan!!!', // 1 byte
|
'hello brendan!!!', // 1 byte
|
||||||
'ΰαβγδεζηθικλμνξο', // 2 bytes
|
'ΰαβγδεζηθικλμνξο', // 2 bytes
|
||||||
'挰挱挲挳挴挵挶挷挸挹挺挻挼挽挾挿', // 3 bytes
|
'挰挱挲挳挴挵挶挷挸挹挺挻挼挽挾挿', // 3 bytes
|
||||||
@ -16,9 +16,9 @@ var chars = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = conf.n | 0;
|
const n = conf.n | 0;
|
||||||
var len = conf.len | 0;
|
const len = conf.len | 0;
|
||||||
var encoding = conf.encoding;
|
const encoding = conf.encoding;
|
||||||
|
|
||||||
var strings = [];
|
var strings = [];
|
||||||
var results;
|
var results;
|
||||||
@ -26,9 +26,9 @@ function main(conf) {
|
|||||||
strings = [ Buffer.alloc(len * 16, 'a') ];
|
strings = [ Buffer.alloc(len * 16, 'a') ];
|
||||||
results = [ len * 16 ];
|
results = [ len * 16 ];
|
||||||
} else {
|
} else {
|
||||||
for (var string of chars) {
|
for (const string of chars) {
|
||||||
// Strings must be built differently, depending on encoding
|
// Strings must be built differently, depending on encoding
|
||||||
var data = string.repeat(len);
|
const data = string.repeat(len);
|
||||||
if (encoding === 'utf8') {
|
if (encoding === 'utf8') {
|
||||||
strings.push(data);
|
strings.push(data);
|
||||||
} else if (encoding === 'base64') {
|
} else if (encoding === 'base64') {
|
||||||
@ -45,9 +45,9 @@ function main(conf) {
|
|||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
var index = n % strings.length;
|
const index = n % strings.length;
|
||||||
// Go!
|
// Go!
|
||||||
var r = Buffer.byteLength(strings[index], encoding);
|
const r = Buffer.byteLength(strings[index], encoding);
|
||||||
|
|
||||||
if (r !== results[index])
|
if (r !== results[index])
|
||||||
throw new Error('incorrect return value');
|
throw new Error('incorrect return value');
|
||||||
|
@ -20,9 +20,9 @@
|
|||||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
size: [16, 512, 1024, 4096, 16386],
|
size: [16, 512, 1024, 4096, 16386],
|
||||||
millions: [1]
|
millions: [1]
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
const searchStrings = [
|
const searchStrings = [
|
||||||
@ -21,7 +21,7 @@ const searchStrings = [
|
|||||||
'</i> to the Caterpillar'
|
'</i> to the Caterpillar'
|
||||||
];
|
];
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
search: searchStrings,
|
search: searchStrings,
|
||||||
encoding: ['undefined', 'utf8', 'ucs2', 'binary'],
|
encoding: ['undefined', 'utf8', 'ucs2', 'binary'],
|
||||||
type: ['buffer', 'string'],
|
type: ['buffer', 'string'],
|
||||||
@ -29,7 +29,7 @@ var bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var iter = (conf.iter) * 100000;
|
const iter = (conf.iter) * 100000;
|
||||||
var aliceBuffer = fs.readFileSync(
|
var aliceBuffer = fs.readFileSync(
|
||||||
path.resolve(__dirname, '../fixtures/alice.html')
|
path.resolve(__dirname, '../fixtures/alice.html')
|
||||||
);
|
);
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var SlowBuffer = require('buffer').SlowBuffer;
|
const SlowBuffer = require('buffer').SlowBuffer;
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
size: [16, 512, 1024, 4096, 16386],
|
size: [16, 512, 1024, 4096, 16386],
|
||||||
type: ['fast', 'slow'],
|
type: ['fast', 'slow'],
|
||||||
method: ['for', 'forOf', 'iterator'],
|
method: ['for', 'forOf', 'iterator'],
|
||||||
n: [1e3]
|
n: [1e3]
|
||||||
});
|
});
|
||||||
|
|
||||||
var methods = {
|
const methods = {
|
||||||
'for': benchFor,
|
'for': benchFor,
|
||||||
'forOf': benchForOf,
|
'forOf': benchForOf,
|
||||||
'iterator': benchIterator
|
'iterator': benchIterator
|
||||||
@ -43,7 +43,7 @@ function benchForOf(buffer, n) {
|
|||||||
bench.start();
|
bench.start();
|
||||||
|
|
||||||
for (var k = 0; k < n; k++) {
|
for (var k = 0; k < n; k++) {
|
||||||
for (var b of buffer) {
|
for (const b of buffer) {
|
||||||
assert(b === 0);
|
assert(b === 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -54,7 +54,7 @@ function benchIterator(buffer, n) {
|
|||||||
bench.start();
|
bench.start();
|
||||||
|
|
||||||
for (var k = 0; k < n; k++) {
|
for (var k = 0; k < n; k++) {
|
||||||
var iter = buffer[Symbol.iterator]();
|
const iter = buffer[Symbol.iterator]();
|
||||||
var cur = iter.next();
|
var cur = iter.next();
|
||||||
|
|
||||||
while (!cur.done) {
|
while (!cur.done) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
|
|
||||||
var types = [
|
const types = [
|
||||||
'UInt8',
|
'UInt8',
|
||||||
'UInt16LE',
|
'UInt16LE',
|
||||||
'UInt16BE',
|
'UInt16BE',
|
||||||
@ -18,7 +18,7 @@ var types = [
|
|||||||
'DoubleBE'
|
'DoubleBE'
|
||||||
];
|
];
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
noAssert: ['false', 'true'],
|
noAssert: ['false', 'true'],
|
||||||
buffer: ['fast', 'slow'],
|
buffer: ['fast', 'slow'],
|
||||||
type: types,
|
type: types,
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var SlowBuffer = require('buffer').SlowBuffer;
|
const SlowBuffer = require('buffer').SlowBuffer;
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
type: ['fast', 'slow'],
|
type: ['fast', 'slow'],
|
||||||
n: [1024]
|
n: [1024]
|
||||||
});
|
});
|
||||||
|
|
||||||
var buf = Buffer.allocUnsafe(1024);
|
const buf = Buffer.allocUnsafe(1024);
|
||||||
var slowBuf = new SlowBuffer(1024);
|
const slowBuf = new SlowBuffer(1024);
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = +conf.n;
|
const n = +conf.n;
|
||||||
var b = conf.type === 'fast' ? buf : slowBuf;
|
const b = conf.type === 'fast' ? buf : slowBuf;
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n * 1024; i++) {
|
for (var i = 0; i < n * 1024; i++) {
|
||||||
b.slice(10, 256);
|
b.slice(10, 256);
|
||||||
|
@ -8,8 +8,8 @@ const bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = +conf.n;
|
const n = +conf.n;
|
||||||
var buf = Buffer.allocUnsafe(+conf.len);
|
const buf = Buffer.allocUnsafe(+conf.len);
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; ++i)
|
for (var i = 0; i < n; ++i)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
|
|
||||||
var types = [
|
const types = [
|
||||||
'UInt8',
|
'UInt8',
|
||||||
'UInt16LE',
|
'UInt16LE',
|
||||||
'UInt16BE',
|
'UInt16BE',
|
||||||
@ -18,7 +18,7 @@ var types = [
|
|||||||
'DoubleBE'
|
'DoubleBE'
|
||||||
];
|
];
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
noAssert: ['false', 'true'],
|
noAssert: ['false', 'true'],
|
||||||
buffer: ['fast', 'slow'],
|
buffer: ['fast', 'slow'],
|
||||||
type: types,
|
type: types,
|
||||||
@ -32,7 +32,7 @@ const UINT8 = (INT8 * 2) + 1;
|
|||||||
const UINT16 = (INT16 * 2) + 1;
|
const UINT16 = (INT16 * 2) + 1;
|
||||||
const UINT32 = INT32;
|
const UINT32 = INT32;
|
||||||
|
|
||||||
var mod = {
|
const mod = {
|
||||||
writeInt8: INT8,
|
writeInt8: INT8,
|
||||||
writeInt16BE: INT16,
|
writeInt16BE: INT16,
|
||||||
writeInt16LE: INT16,
|
writeInt16LE: INT16,
|
||||||
@ -60,8 +60,8 @@ function main(conf) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function benchInt(buff, fn, len, noAssert) {
|
function benchInt(buff, fn, len, noAssert) {
|
||||||
var m = mod[fn];
|
const m = mod[fn];
|
||||||
var testFunction = new Function('buff', `
|
const 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)});
|
||||||
}
|
}
|
||||||
@ -72,7 +72,7 @@ function benchInt(buff, fn, len, noAssert) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function benchFloat(buff, fn, len, noAssert) {
|
function benchFloat(buff, fn, len, noAssert) {
|
||||||
var testFunction = new Function('buff', `
|
const 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)});
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ const zeroBuffer = Buffer.alloc(0);
|
|||||||
const zeroString = '';
|
const zeroString = '';
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = +conf.n;
|
const n = +conf.n;
|
||||||
bench.start();
|
bench.start();
|
||||||
|
|
||||||
if (conf.type === 'buffer')
|
if (conf.type === 'buffer')
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
|
|
||||||
var types = [
|
const types = [
|
||||||
'Uint8',
|
'Uint8',
|
||||||
'Uint16LE',
|
'Uint16LE',
|
||||||
'Uint16BE',
|
'Uint16BE',
|
||||||
@ -18,7 +18,7 @@ var types = [
|
|||||||
'Float64BE'
|
'Float64BE'
|
||||||
];
|
];
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
type: types,
|
type: types,
|
||||||
millions: [1]
|
millions: [1]
|
||||||
});
|
});
|
||||||
@ -30,7 +30,7 @@ const UINT8 = INT8 * 2;
|
|||||||
const UINT16 = INT16 * 2;
|
const UINT16 = INT16 * 2;
|
||||||
const UINT32 = INT32 * 2;
|
const UINT32 = INT32 * 2;
|
||||||
|
|
||||||
var mod = {
|
const mod = {
|
||||||
setInt8: INT8,
|
setInt8: INT8,
|
||||||
setInt16: INT16,
|
setInt16: INT16,
|
||||||
setInt32: INT32,
|
setInt32: INT32,
|
||||||
|
@ -3,7 +3,7 @@ const common = require('../common.js');
|
|||||||
const { exec, execSync } = require('child_process');
|
const { exec, execSync } = require('child_process');
|
||||||
const isWindows = process.platform === 'win32';
|
const isWindows = process.platform === 'win32';
|
||||||
|
|
||||||
var messagesLength = [64, 256, 1024, 4096];
|
const messagesLength = [64, 256, 1024, 4096];
|
||||||
// Windows does not support command lines longer than 8191 characters
|
// Windows does not support command lines longer than 8191 characters
|
||||||
if (!isWindows) messagesLength.push(32768);
|
if (!isWindows) messagesLength.push(32768);
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ const common = require('../common.js');
|
|||||||
const os = require('os');
|
const os = require('os');
|
||||||
const child_process = require('child_process');
|
const child_process = require('child_process');
|
||||||
|
|
||||||
var messagesLength = [64, 256, 1024, 4096];
|
const messagesLength = [64, 256, 1024, 4096];
|
||||||
// Windows does not support that long arguments
|
// Windows does not support that long arguments
|
||||||
if (os.platform() !== 'win32')
|
if (os.platform() !== 'win32')
|
||||||
messagesLength.push(32768);
|
messagesLength.push(32768);
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
n: [1000]
|
n: [1000]
|
||||||
});
|
});
|
||||||
|
|
||||||
var spawn = require('child_process').spawn;
|
const spawn = require('child_process').spawn;
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = +conf.n;
|
const n = +conf.n;
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
go(n, n);
|
go(n, n);
|
||||||
@ -16,7 +16,7 @@ function go(n, left) {
|
|||||||
if (--left === 0)
|
if (--left === 0)
|
||||||
return bench.end(n);
|
return bench.end(n);
|
||||||
|
|
||||||
var child = spawn('echo', ['hello']);
|
const child = spawn('echo', ['hello']);
|
||||||
child.on('exit', function(code) {
|
child.on('exit', function(code) {
|
||||||
if (code)
|
if (code)
|
||||||
process.exit(code);
|
process.exit(code);
|
||||||
|
@ -11,10 +11,10 @@ if (cluster.isMaster) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = +conf.n;
|
const n = +conf.n;
|
||||||
var workers = +conf.workers;
|
const workers = +conf.workers;
|
||||||
var sends = +conf.sendsPerBroadcast;
|
const sends = +conf.sendsPerBroadcast;
|
||||||
var expectedPerBroadcast = sends * workers;
|
const expectedPerBroadcast = sends * workers;
|
||||||
var payload;
|
var payload;
|
||||||
var readies = 0;
|
var readies = 0;
|
||||||
var broadcasts = 0;
|
var broadcasts = 0;
|
||||||
|
@ -1,34 +1,34 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
var keylen = { 'aes-128-gcm': 16, 'aes-192-gcm': 24, 'aes-256-gcm': 32 };
|
const keylen = { 'aes-128-gcm': 16, 'aes-192-gcm': 24, 'aes-256-gcm': 32 };
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
n: [500],
|
n: [500],
|
||||||
cipher: ['aes-128-gcm', 'aes-192-gcm', 'aes-256-gcm'],
|
cipher: ['aes-128-gcm', 'aes-192-gcm', 'aes-256-gcm'],
|
||||||
len: [1024, 4 * 1024, 16 * 1024, 64 * 1024, 256 * 1024, 1024 * 1024]
|
len: [1024, 4 * 1024, 16 * 1024, 64 * 1024, 256 * 1024, 1024 * 1024]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var message = Buffer.alloc(conf.len, 'b');
|
const message = Buffer.alloc(conf.len, 'b');
|
||||||
var key = crypto.randomBytes(keylen[conf.cipher]);
|
const key = crypto.randomBytes(keylen[conf.cipher]);
|
||||||
var iv = crypto.randomBytes(12);
|
const iv = crypto.randomBytes(12);
|
||||||
var associate_data = Buffer.alloc(16, 'z');
|
const associate_data = Buffer.alloc(16, 'z');
|
||||||
bench.start();
|
bench.start();
|
||||||
AEAD_Bench(conf.cipher, message, associate_data, key, iv, conf.n, conf.len);
|
AEAD_Bench(conf.cipher, message, associate_data, key, iv, conf.n, conf.len);
|
||||||
}
|
}
|
||||||
|
|
||||||
function AEAD_Bench(cipher, message, associate_data, key, iv, n, len) {
|
function AEAD_Bench(cipher, message, associate_data, key, iv, n, len) {
|
||||||
var written = n * len;
|
const written = n * len;
|
||||||
var bits = written * 8;
|
const bits = written * 8;
|
||||||
var mbits = bits / (1024 * 1024);
|
const mbits = bits / (1024 * 1024);
|
||||||
|
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
var alice = crypto.createCipheriv(cipher, key, iv);
|
const alice = crypto.createCipheriv(cipher, key, iv);
|
||||||
alice.setAAD(associate_data);
|
alice.setAAD(associate_data);
|
||||||
var enc = alice.update(message);
|
const enc = alice.update(message);
|
||||||
alice.final();
|
alice.final();
|
||||||
var tag = alice.getAuthTag();
|
const tag = alice.getAuthTag();
|
||||||
var bob = crypto.createDecipheriv(cipher, key, iv);
|
const bob = crypto.createDecipheriv(cipher, key, iv);
|
||||||
bob.setAuthTag(tag);
|
bob.setAuthTag(tag);
|
||||||
bob.setAAD(associate_data);
|
bob.setAAD(associate_data);
|
||||||
bob.update(enc);
|
bob.update(enc);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
writes: [500],
|
writes: [500],
|
||||||
cipher: [ 'AES192', 'AES256' ],
|
cipher: [ 'AES192', 'AES256' ],
|
||||||
type: ['asc', 'utf', 'buf'],
|
type: ['asc', 'utf', 'buf'],
|
||||||
@ -17,24 +17,24 @@ function main(conf) {
|
|||||||
api = 'legacy';
|
api = 'legacy';
|
||||||
}
|
}
|
||||||
|
|
||||||
var crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
var assert = require('assert');
|
const assert = require('assert');
|
||||||
var alice = crypto.getDiffieHellman('modp5');
|
const alice = crypto.getDiffieHellman('modp5');
|
||||||
var bob = crypto.getDiffieHellman('modp5');
|
const bob = crypto.getDiffieHellman('modp5');
|
||||||
|
|
||||||
alice.generateKeys();
|
alice.generateKeys();
|
||||||
bob.generateKeys();
|
bob.generateKeys();
|
||||||
|
|
||||||
|
|
||||||
var pubEnc = /^v0\.[0-8]/.test(process.version) ? 'binary' : null;
|
const pubEnc = /^v0\.[0-8]/.test(process.version) ? 'binary' : null;
|
||||||
var alice_secret = alice.computeSecret(bob.getPublicKey(), pubEnc, 'hex');
|
const alice_secret = alice.computeSecret(bob.getPublicKey(), pubEnc, 'hex');
|
||||||
var bob_secret = bob.computeSecret(alice.getPublicKey(), pubEnc, 'hex');
|
const bob_secret = bob.computeSecret(alice.getPublicKey(), pubEnc, 'hex');
|
||||||
|
|
||||||
// alice_secret and bob_secret should be the same
|
// alice_secret and bob_secret should be the same
|
||||||
assert(alice_secret === bob_secret);
|
assert(alice_secret === bob_secret);
|
||||||
|
|
||||||
var alice_cipher = crypto.createCipher(conf.cipher, alice_secret);
|
const alice_cipher = crypto.createCipher(conf.cipher, alice_secret);
|
||||||
var bob_cipher = crypto.createDecipher(conf.cipher, bob_secret);
|
const bob_cipher = crypto.createDecipher(conf.cipher, bob_secret);
|
||||||
|
|
||||||
var message;
|
var message;
|
||||||
var encoding;
|
var encoding;
|
||||||
@ -54,7 +54,7 @@ function main(conf) {
|
|||||||
throw new Error(`unknown message type: ${conf.type}`);
|
throw new Error(`unknown message type: ${conf.type}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
var fn = api === 'stream' ? streamWrite : legacyWrite;
|
const fn = api === 'stream' ? streamWrite : legacyWrite;
|
||||||
|
|
||||||
// write data as fast as possible to alice, and have bob decrypt.
|
// write data as fast as possible to alice, and have bob decrypt.
|
||||||
// use old API for comparison to v0.8
|
// use old API for comparison to v0.8
|
||||||
@ -70,8 +70,8 @@ function streamWrite(alice, bob, message, encoding, writes) {
|
|||||||
|
|
||||||
bob.on('end', function() {
|
bob.on('end', function() {
|
||||||
// Gbits
|
// Gbits
|
||||||
var bits = written * 8;
|
const bits = written * 8;
|
||||||
var gbits = bits / (1024 * 1024 * 1024);
|
const gbits = bits / (1024 * 1024 * 1024);
|
||||||
bench.end(gbits);
|
bench.end(gbits);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -96,6 +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 gbits = written / (1024 * 1024 * 1024);
|
const gbits = written / (1024 * 1024 * 1024);
|
||||||
bench.end(gbits);
|
bench.end(gbits);
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
// throughput benchmark
|
// throughput benchmark
|
||||||
// creates a single hasher, then pushes a bunch of data through it
|
// creates a single hasher, then pushes a bunch of data through it
|
||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
writes: [500],
|
writes: [500],
|
||||||
algo: [ 'sha256', 'md5' ],
|
algo: [ 'sha256', 'md5' ],
|
||||||
type: ['asc', 'utf', 'buf'],
|
type: ['asc', 'utf', 'buf'],
|
||||||
@ -39,19 +39,19 @@ function main(conf) {
|
|||||||
throw new Error(`unknown message type: ${conf.type}`);
|
throw new Error(`unknown message type: ${conf.type}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
var fn = api === 'stream' ? streamWrite : legacyWrite;
|
const fn = api === 'stream' ? streamWrite : legacyWrite;
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
fn(conf.algo, message, encoding, conf.writes, conf.len, conf.out);
|
fn(conf.algo, message, encoding, conf.writes, conf.len, conf.out);
|
||||||
}
|
}
|
||||||
|
|
||||||
function legacyWrite(algo, message, encoding, writes, len, outEnc) {
|
function legacyWrite(algo, message, encoding, writes, len, outEnc) {
|
||||||
var written = writes * len;
|
const written = writes * len;
|
||||||
var bits = written * 8;
|
const bits = written * 8;
|
||||||
var gbits = bits / (1024 * 1024 * 1024);
|
const gbits = bits / (1024 * 1024 * 1024);
|
||||||
|
|
||||||
while (writes-- > 0) {
|
while (writes-- > 0) {
|
||||||
var h = crypto.createHash(algo);
|
const h = crypto.createHash(algo);
|
||||||
h.update(message, encoding);
|
h.update(message, encoding);
|
||||||
var res = h.digest(outEnc);
|
var res = h.digest(outEnc);
|
||||||
|
|
||||||
@ -64,12 +64,12 @@ function legacyWrite(algo, message, encoding, writes, len, outEnc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function streamWrite(algo, message, encoding, writes, len, outEnc) {
|
function streamWrite(algo, message, encoding, writes, len, outEnc) {
|
||||||
var written = writes * len;
|
const written = writes * len;
|
||||||
var bits = written * 8;
|
const bits = written * 8;
|
||||||
var gbits = bits / (1024 * 1024 * 1024);
|
const gbits = bits / (1024 * 1024 * 1024);
|
||||||
|
|
||||||
while (writes-- > 0) {
|
while (writes-- > 0) {
|
||||||
var h = crypto.createHash(algo);
|
const h = crypto.createHash(algo);
|
||||||
|
|
||||||
if (outEnc !== 'buffer')
|
if (outEnc !== 'buffer')
|
||||||
h.setEncoding(outEnc);
|
h.setEncoding(outEnc);
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
// throughput benchmark
|
// throughput benchmark
|
||||||
// creates a single hasher, then pushes a bunch of data through it
|
// creates a single hasher, then pushes a bunch of data through it
|
||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
writes: [500],
|
writes: [500],
|
||||||
algo: ['sha1', 'sha256', 'sha512'],
|
algo: ['sha1', 'sha256', 'sha512'],
|
||||||
type: ['asc', 'utf', 'buf'],
|
type: ['asc', 'utf', 'buf'],
|
||||||
@ -38,17 +38,17 @@ function main(conf) {
|
|||||||
throw new Error(`unknown message type: ${conf.type}`);
|
throw new Error(`unknown message type: ${conf.type}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
var fn = api === 'stream' ? streamWrite : legacyWrite;
|
const fn = api === 'stream' ? streamWrite : legacyWrite;
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
fn(conf.algo, message, encoding, conf.writes, conf.len);
|
fn(conf.algo, message, encoding, conf.writes, conf.len);
|
||||||
}
|
}
|
||||||
|
|
||||||
function legacyWrite(algo, message, encoding, writes, len) {
|
function legacyWrite(algo, message, encoding, writes, len) {
|
||||||
var written = writes * len;
|
const written = writes * len;
|
||||||
var bits = written * 8;
|
const bits = written * 8;
|
||||||
var gbits = bits / (1024 * 1024 * 1024);
|
const gbits = bits / (1024 * 1024 * 1024);
|
||||||
var h = crypto.createHash(algo);
|
const h = crypto.createHash(algo);
|
||||||
|
|
||||||
while (writes-- > 0)
|
while (writes-- > 0)
|
||||||
h.update(message, encoding);
|
h.update(message, encoding);
|
||||||
@ -59,10 +59,10 @@ function legacyWrite(algo, message, encoding, writes, len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function streamWrite(algo, message, encoding, writes, len) {
|
function streamWrite(algo, message, encoding, writes, len) {
|
||||||
var written = writes * len;
|
const written = writes * len;
|
||||||
var bits = written * 8;
|
const bits = written * 8;
|
||||||
var gbits = bits / (1024 * 1024 * 1024);
|
const gbits = bits / (1024 * 1024 * 1024);
|
||||||
var h = crypto.createHash(algo);
|
const h = crypto.createHash(algo);
|
||||||
|
|
||||||
while (writes-- > 0)
|
while (writes-- > 0)
|
||||||
h.write(message, encoding);
|
h.write(message, encoding);
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
// throughput benchmark in signing and verifying
|
// throughput benchmark in signing and verifying
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
var fs = require('fs');
|
const fs = require('fs');
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
var fixtures_keydir = path.resolve(__dirname, '../../test/fixtures/keys/');
|
const fixtures_keydir = path.resolve(__dirname, '../../test/fixtures/keys/');
|
||||||
var keylen_list = ['1024', '2048', '4096'];
|
const keylen_list = ['1024', '2048', '4096'];
|
||||||
var RSA_PublicPem = {};
|
const RSA_PublicPem = {};
|
||||||
var RSA_PrivatePem = {};
|
const RSA_PrivatePem = {};
|
||||||
|
|
||||||
keylen_list.forEach(function(key) {
|
keylen_list.forEach(function(key) {
|
||||||
RSA_PublicPem[key] =
|
RSA_PublicPem[key] =
|
||||||
@ -16,27 +16,27 @@ keylen_list.forEach(function(key) {
|
|||||||
fs.readFileSync(`${fixtures_keydir}/rsa_private_${key}.pem`);
|
fs.readFileSync(`${fixtures_keydir}/rsa_private_${key}.pem`);
|
||||||
});
|
});
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
n: [500],
|
n: [500],
|
||||||
keylen: keylen_list,
|
keylen: keylen_list,
|
||||||
len: [16, 32, 64]
|
len: [16, 32, 64]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var message = Buffer.alloc(conf.len, 'b');
|
const message = Buffer.alloc(conf.len, 'b');
|
||||||
bench.start();
|
bench.start();
|
||||||
StreamWrite(conf.algo, conf.keylen, message, conf.n, conf.len);
|
StreamWrite(conf.algo, conf.keylen, message, conf.n, conf.len);
|
||||||
}
|
}
|
||||||
|
|
||||||
function StreamWrite(algo, keylen, message, n, len) {
|
function StreamWrite(algo, keylen, message, n, len) {
|
||||||
var written = n * len;
|
const written = n * len;
|
||||||
var bits = written * 8;
|
const bits = written * 8;
|
||||||
var kbits = bits / (1024);
|
const kbits = bits / (1024);
|
||||||
|
|
||||||
var privateKey = RSA_PrivatePem[keylen];
|
const privateKey = RSA_PrivatePem[keylen];
|
||||||
var publicKey = RSA_PublicPem[keylen];
|
const publicKey = RSA_PublicPem[keylen];
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
var enc = crypto.privateEncrypt(privateKey, message);
|
const enc = crypto.privateEncrypt(privateKey, message);
|
||||||
crypto.publicDecrypt(publicKey, enc);
|
crypto.publicDecrypt(publicKey, enc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
// throughput benchmark in signing and verifying
|
// throughput benchmark in signing and verifying
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
var fs = require('fs');
|
const fs = require('fs');
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
var fixtures_keydir = path.resolve(__dirname, '../../test/fixtures/keys/');
|
const fixtures_keydir = path.resolve(__dirname, '../../test/fixtures/keys/');
|
||||||
var keylen_list = ['1024', '2048'];
|
const keylen_list = ['1024', '2048'];
|
||||||
var RSA_PublicPem = {};
|
const RSA_PublicPem = {};
|
||||||
var RSA_PrivatePem = {};
|
const RSA_PrivatePem = {};
|
||||||
|
|
||||||
keylen_list.forEach(function(key) {
|
keylen_list.forEach(function(key) {
|
||||||
RSA_PublicPem[key] =
|
RSA_PublicPem[key] =
|
||||||
@ -16,7 +16,7 @@ keylen_list.forEach(function(key) {
|
|||||||
fs.readFileSync(`${fixtures_keydir}/rsa_private_${key}.pem`);
|
fs.readFileSync(`${fixtures_keydir}/rsa_private_${key}.pem`);
|
||||||
});
|
});
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
writes: [500],
|
writes: [500],
|
||||||
algo: ['SHA1', 'SHA224', 'SHA256', 'SHA384', 'SHA512'],
|
algo: ['SHA1', 'SHA224', 'SHA256', 'SHA384', 'SHA512'],
|
||||||
keylen: keylen_list,
|
keylen: keylen_list,
|
||||||
@ -24,19 +24,19 @@ var bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var message = Buffer.alloc(conf.len, 'b');
|
const message = Buffer.alloc(conf.len, 'b');
|
||||||
bench.start();
|
bench.start();
|
||||||
StreamWrite(conf.algo, conf.keylen, message, conf.writes, conf.len);
|
StreamWrite(conf.algo, conf.keylen, message, conf.writes, conf.len);
|
||||||
}
|
}
|
||||||
|
|
||||||
function StreamWrite(algo, keylen, message, writes, len) {
|
function StreamWrite(algo, keylen, message, writes, len) {
|
||||||
var written = writes * len;
|
const written = writes * len;
|
||||||
var bits = written * 8;
|
const bits = written * 8;
|
||||||
var kbits = bits / (1024);
|
const kbits = bits / (1024);
|
||||||
|
|
||||||
var privateKey = RSA_PrivatePem[keylen];
|
const privateKey = RSA_PrivatePem[keylen];
|
||||||
var s = crypto.createSign(algo);
|
const s = crypto.createSign(algo);
|
||||||
var v = crypto.createVerify(algo);
|
const v = crypto.createVerify(algo);
|
||||||
|
|
||||||
while (writes-- > 0) {
|
while (writes-- > 0) {
|
||||||
s.update(message);
|
s.update(message);
|
||||||
|
@ -7,7 +7,7 @@ const PORT = common.PORT;
|
|||||||
// `num` is the number of send requests to queue up each time.
|
// `num` is the number of send requests to queue up each time.
|
||||||
// Keep it reasonably high (>10) otherwise you're benchmarking the speed of
|
// Keep it reasonably high (>10) otherwise you're benchmarking the speed of
|
||||||
// event loop cycles more than anything else.
|
// event loop cycles more than anything else.
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
len: [64, 256, 512, 1024],
|
len: [64, 256, 512, 1024],
|
||||||
num: [100],
|
num: [100],
|
||||||
chunks: [1, 2, 4, 8],
|
chunks: [1, 2, 4, 8],
|
||||||
@ -37,13 +37,13 @@ function main(conf) {
|
|||||||
server();
|
server();
|
||||||
}
|
}
|
||||||
|
|
||||||
var dgram = require('dgram');
|
const dgram = require('dgram');
|
||||||
|
|
||||||
function server() {
|
function server() {
|
||||||
var sent = 0;
|
var sent = 0;
|
||||||
var socket = dgram.createSocket('udp4');
|
const socket = dgram.createSocket('udp4');
|
||||||
|
|
||||||
var onsend = type === 'concat' ? onsendConcat : onsendMulti;
|
const onsend = type === 'concat' ? onsendConcat : onsendMulti;
|
||||||
|
|
||||||
function onsendConcat() {
|
function onsendConcat() {
|
||||||
if (sent++ % num === 0) {
|
if (sent++ % num === 0) {
|
||||||
@ -66,8 +66,8 @@ function server() {
|
|||||||
onsend();
|
onsend();
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
var bytes = sent * len;
|
const bytes = sent * len;
|
||||||
var gbits = (bytes * 8) / (1024 * 1024 * 1024);
|
const gbits = (bytes * 8) / (1024 * 1024 * 1024);
|
||||||
bench.end(gbits);
|
bench.end(gbits);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}, dur * 1000);
|
}, dur * 1000);
|
||||||
|
@ -7,7 +7,7 @@ const PORT = common.PORT;
|
|||||||
// `num` is the number of send requests to queue up each time.
|
// `num` is the number of send requests to queue up each time.
|
||||||
// Keep it reasonably high (>10) otherwise you're benchmarking the speed of
|
// Keep it reasonably high (>10) otherwise you're benchmarking the speed of
|
||||||
// event loop cycles more than anything else.
|
// event loop cycles more than anything else.
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
len: [64, 256, 1024],
|
len: [64, 256, 1024],
|
||||||
num: [100],
|
num: [100],
|
||||||
chunks: [1, 2, 4, 8],
|
chunks: [1, 2, 4, 8],
|
||||||
@ -37,12 +37,12 @@ function main(conf) {
|
|||||||
server();
|
server();
|
||||||
}
|
}
|
||||||
|
|
||||||
var dgram = require('dgram');
|
const dgram = require('dgram');
|
||||||
|
|
||||||
function server() {
|
function server() {
|
||||||
var sent = 0;
|
var sent = 0;
|
||||||
var received = 0;
|
var received = 0;
|
||||||
var socket = dgram.createSocket('udp4');
|
const socket = dgram.createSocket('udp4');
|
||||||
|
|
||||||
function onsend() {
|
function onsend() {
|
||||||
if (sent++ % num === 0) {
|
if (sent++ % num === 0) {
|
||||||
@ -57,8 +57,8 @@ function server() {
|
|||||||
onsend();
|
onsend();
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
var bytes = (type === 'send' ? sent : received) * len;
|
const bytes = (type === 'send' ? sent : received) * len;
|
||||||
var gbits = (bytes * 8) / (1024 * 1024 * 1024);
|
const gbits = (bytes * 8) / (1024 * 1024 * 1024);
|
||||||
bench.end(gbits);
|
bench.end(gbits);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}, dur * 1000);
|
}, dur * 1000);
|
||||||
|
@ -7,7 +7,7 @@ const PORT = common.PORT;
|
|||||||
// `num` is the number of send requests to queue up each time.
|
// `num` is the number of send requests to queue up each time.
|
||||||
// Keep it reasonably high (>10) otherwise you're benchmarking the speed of
|
// Keep it reasonably high (>10) otherwise you're benchmarking the speed of
|
||||||
// event loop cycles more than anything else.
|
// event loop cycles more than anything else.
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
len: [1, 64, 256, 1024],
|
len: [1, 64, 256, 1024],
|
||||||
num: [100],
|
num: [100],
|
||||||
type: ['send', 'recv'],
|
type: ['send', 'recv'],
|
||||||
@ -29,12 +29,12 @@ function main(conf) {
|
|||||||
server();
|
server();
|
||||||
}
|
}
|
||||||
|
|
||||||
var dgram = require('dgram');
|
const dgram = require('dgram');
|
||||||
|
|
||||||
function server() {
|
function server() {
|
||||||
var sent = 0;
|
var sent = 0;
|
||||||
var received = 0;
|
var received = 0;
|
||||||
var socket = dgram.createSocket('udp4');
|
const socket = dgram.createSocket('udp4');
|
||||||
|
|
||||||
function onsend() {
|
function onsend() {
|
||||||
if (sent++ % num === 0) {
|
if (sent++ % num === 0) {
|
||||||
@ -49,8 +49,8 @@ function server() {
|
|||||||
onsend();
|
onsend();
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
var bytes = (type === 'send' ? sent : received) * chunk.length;
|
const bytes = (type === 'send' ? sent : received) * chunk.length;
|
||||||
var gbits = (bytes * 8) / (1024 * 1024 * 1024);
|
const gbits = (bytes * 8) / (1024 * 1024 * 1024);
|
||||||
bench.end(gbits);
|
bench.end(gbits);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}, dur * 1000);
|
}, dur * 1000);
|
||||||
|
@ -7,7 +7,7 @@ const PORT = common.PORT;
|
|||||||
// `num` is the number of send requests to queue up each time.
|
// `num` is the number of send requests to queue up each time.
|
||||||
// Keep it reasonably high (>10) otherwise you're benchmarking the speed of
|
// Keep it reasonably high (>10) otherwise you're benchmarking the speed of
|
||||||
// event loop cycles more than anything else.
|
// event loop cycles more than anything else.
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
len: [1, 64, 256, 1024],
|
len: [1, 64, 256, 1024],
|
||||||
num: [100],
|
num: [100],
|
||||||
type: ['send', 'recv'],
|
type: ['send', 'recv'],
|
||||||
@ -29,12 +29,12 @@ function main(conf) {
|
|||||||
server();
|
server();
|
||||||
}
|
}
|
||||||
|
|
||||||
var dgram = require('dgram');
|
const dgram = require('dgram');
|
||||||
|
|
||||||
function server() {
|
function server() {
|
||||||
var sent = 0;
|
var sent = 0;
|
||||||
var received = 0;
|
var received = 0;
|
||||||
var socket = dgram.createSocket('udp4');
|
const socket = dgram.createSocket('udp4');
|
||||||
|
|
||||||
function onsend() {
|
function onsend() {
|
||||||
if (sent++ % num === 0) {
|
if (sent++ % num === 0) {
|
||||||
@ -49,8 +49,8 @@ function server() {
|
|||||||
onsend();
|
onsend();
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
var bytes = (type === 'send' ? sent : received) * chunk.length;
|
const bytes = (type === 'send' ? sent : received) * chunk.length;
|
||||||
var gbits = (bytes * 8) / (1024 * 1024 * 1024);
|
const gbits = (bytes * 8) / (1024 * 1024 * 1024);
|
||||||
bench.end(gbits);
|
bench.end(gbits);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}, dur * 1000);
|
}, dur * 1000);
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var domain = require('domain');
|
const domain = require('domain');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
arguments: [0, 1, 2, 3],
|
arguments: [0, 1, 2, 3],
|
||||||
n: [10]
|
n: [10]
|
||||||
});
|
});
|
||||||
|
|
||||||
var bdomain = domain.create();
|
const bdomain = domain.create();
|
||||||
var gargs = [1, 2, 3];
|
const gargs = [1, 2, 3];
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
|
|
||||||
var n = +conf.n;
|
const n = +conf.n;
|
||||||
var myArguments = gargs.slice(0, conf.arguments);
|
const myArguments = gargs.slice(0, conf.arguments);
|
||||||
bench.start();
|
bench.start();
|
||||||
|
|
||||||
bdomain.enter();
|
bdomain.enter();
|
||||||
|
@ -9,13 +9,13 @@ const bench = common.createBenchmark(main, {
|
|||||||
|
|
||||||
function runNormal(n) {
|
function runNormal(n) {
|
||||||
var i = 0;
|
var i = 0;
|
||||||
var o = { x: 0, y: 1 };
|
const o = { x: 0, y: 1 };
|
||||||
bench.start();
|
bench.start();
|
||||||
for (; i < n; i++) {
|
for (; i < n; i++) {
|
||||||
/* eslint-disable no-unused-vars */
|
/* eslint-disable no-unused-vars */
|
||||||
var x = o.x;
|
const x = o.x;
|
||||||
var y = o.y;
|
const y = o.y;
|
||||||
var r = o.r || 2;
|
const r = o.r || 2;
|
||||||
/* eslint-enable no-unused-vars */
|
/* eslint-enable no-unused-vars */
|
||||||
}
|
}
|
||||||
bench.end(n / 1e6);
|
bench.end(n / 1e6);
|
||||||
@ -23,11 +23,11 @@ function runNormal(n) {
|
|||||||
|
|
||||||
function runDestructured(n) {
|
function runDestructured(n) {
|
||||||
var i = 0;
|
var i = 0;
|
||||||
var o = { x: 0, y: 1 };
|
const o = { x: 0, y: 1 };
|
||||||
bench.start();
|
bench.start();
|
||||||
for (; i < n; i++) {
|
for (; i < n; i++) {
|
||||||
/* eslint-disable no-unused-vars */
|
/* eslint-disable no-unused-vars */
|
||||||
var { x, y, r = 2 } = o;
|
const { x, y, r = 2 } = o;
|
||||||
/* eslint-enable no-unused-vars */
|
/* eslint-enable no-unused-vars */
|
||||||
}
|
}
|
||||||
bench.end(n / 1e6);
|
bench.end(n / 1e6);
|
||||||
|
@ -14,7 +14,7 @@ function useFor(n, items, count) {
|
|||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
for (j = 0; j < count; j++) {
|
for (j = 0; j < count; j++) {
|
||||||
/* eslint-disable no-unused-vars */
|
/* eslint-disable no-unused-vars */
|
||||||
var item = items[j];
|
const item = items[j];
|
||||||
/* esline-enable no-unused-vars */
|
/* esline-enable no-unused-vars */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,8 @@ const bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function copyArguments() {
|
function copyArguments() {
|
||||||
var len = arguments.length;
|
const len = arguments.length;
|
||||||
var args = new Array(len);
|
const args = new Array(len);
|
||||||
for (var i = 0; i < len; i++)
|
for (var i = 0; i < len; i++)
|
||||||
args[i] = arguments[i];
|
args[i] = arguments[i];
|
||||||
assert.strictEqual(args[0], 1);
|
assert.strictEqual(args[0], 1);
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var events = require('events');
|
const events = require('events');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, { n: [25e4] });
|
const bench = common.createBenchmark(main, { n: [25e4] });
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = conf.n | 0;
|
const n = conf.n | 0;
|
||||||
|
|
||||||
var ee = new events.EventEmitter();
|
const ee = new events.EventEmitter();
|
||||||
var listeners = [];
|
const listeners = [];
|
||||||
|
|
||||||
var k;
|
var k;
|
||||||
for (k = 0; k < 10; k += 1)
|
for (k = 0; k < 10; k += 1)
|
||||||
@ -16,7 +16,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 dummy = (i % 2 === 0) ? 'dummy0' : 'dummy1';
|
const dummy = (i % 2 === 0) ? 'dummy0' : 'dummy1';
|
||||||
for (k = listeners.length; --k >= 0; /* empty */) {
|
for (k = listeners.length; --k >= 0; /* empty */) {
|
||||||
ee.on(dummy, listeners[k]);
|
ee.on(dummy, listeners[k]);
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var EventEmitter = require('events').EventEmitter;
|
const EventEmitter = require('events').EventEmitter;
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, { n: [2e6] });
|
const bench = common.createBenchmark(main, { n: [2e6] });
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = conf.n | 0;
|
const n = conf.n | 0;
|
||||||
|
|
||||||
var ee = new EventEmitter();
|
const ee = new EventEmitter();
|
||||||
|
|
||||||
for (var k = 0; k < 10; k += 1)
|
for (var k = 0; k < 10; k += 1)
|
||||||
ee.on('dummy', function() {});
|
ee.on('dummy', function() {});
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var EventEmitter = require('events').EventEmitter;
|
const EventEmitter = require('events').EventEmitter;
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, { n: [2e6] });
|
const bench = common.createBenchmark(main, { n: [2e6] });
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = conf.n | 0;
|
const n = conf.n | 0;
|
||||||
|
|
||||||
var ee = new EventEmitter();
|
const ee = new EventEmitter();
|
||||||
|
|
||||||
for (var k = 0; k < 10; k += 1)
|
for (var k = 0; k < 10; k += 1)
|
||||||
ee.on('dummy', function() {});
|
ee.on('dummy', function() {});
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var EventEmitter = require('events').EventEmitter;
|
const EventEmitter = require('events').EventEmitter;
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, { n: [5e7] });
|
const bench = common.createBenchmark(main, { n: [5e7] });
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = conf.n | 0;
|
const n = conf.n | 0;
|
||||||
|
|
||||||
var 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', function() {});
|
||||||
@ -16,7 +16,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 dummy = (i % 2 === 0) ? 'dummy0' : 'dummy1';
|
const dummy = (i % 2 === 0) ? 'dummy0' : 'dummy1';
|
||||||
ee.listenerCount(dummy);
|
ee.listenerCount(dummy);
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var EventEmitter = require('events').EventEmitter;
|
const EventEmitter = require('events').EventEmitter;
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, { n: [5e6] });
|
const bench = common.createBenchmark(main, { n: [5e6] });
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = conf.n | 0;
|
const n = conf.n | 0;
|
||||||
|
|
||||||
var ee = new EventEmitter();
|
const ee = new EventEmitter();
|
||||||
ee.setMaxListeners(101);
|
ee.setMaxListeners(101);
|
||||||
|
|
||||||
for (var k = 0; k < 50; k += 1) {
|
for (var k = 0; k < 50; k += 1) {
|
||||||
@ -17,7 +17,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 dummy = (i % 2 === 0) ? 'dummy0' : 'dummy1';
|
const dummy = (i % 2 === 0) ? 'dummy0' : 'dummy1';
|
||||||
ee.listeners(dummy);
|
ee.listeners(dummy);
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var EventEmitter = require('events').EventEmitter;
|
const EventEmitter = require('events').EventEmitter;
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, { n: [5e6] });
|
const bench = common.createBenchmark(main, { n: [5e6] });
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = conf.n | 0;
|
const n = conf.n | 0;
|
||||||
|
|
||||||
var 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', function() {});
|
||||||
@ -16,7 +16,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 dummy = (i % 2 === 0) ? 'dummy0' : 'dummy1';
|
const dummy = (i % 2 === 0) ? 'dummy0' : 'dummy1';
|
||||||
ee.listeners(dummy);
|
ee.listeners(dummy);
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var EventEmitter = require('events').EventEmitter;
|
const EventEmitter = require('events').EventEmitter;
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, { n: [2e7] });
|
const bench = common.createBenchmark(main, { n: [2e7] });
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = conf.n | 0;
|
const n = conf.n | 0;
|
||||||
|
|
||||||
var ee = new EventEmitter();
|
const ee = new EventEmitter();
|
||||||
|
|
||||||
function listener() {}
|
function listener() {}
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i += 1) {
|
for (var i = 0; i < n; i += 1) {
|
||||||
var dummy = (i % 2 === 0) ? 'dummy0' : 'dummy1';
|
const dummy = (i % 2 === 0) ? 'dummy0' : 'dummy1';
|
||||||
ee.once(dummy, listener);
|
ee.once(dummy, listener);
|
||||||
ee.emit(dummy);
|
ee.emit(dummy);
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var http = require('http');
|
const http = require('http');
|
||||||
|
|
||||||
var fixed = 'C'.repeat(20 * 1024);
|
const fixed = 'C'.repeat(20 * 1024);
|
||||||
var storedBytes = Object.create(null);
|
const storedBytes = Object.create(null);
|
||||||
var storedBuffer = Object.create(null);
|
const storedBuffer = Object.create(null);
|
||||||
var storedUnicode = Object.create(null);
|
const storedUnicode = Object.create(null);
|
||||||
|
|
||||||
var useDomains = process.env.NODE_USE_DOMAINS;
|
const useDomains = process.env.NODE_USE_DOMAINS;
|
||||||
|
|
||||||
// set up one global domain.
|
// set up one global domain.
|
||||||
if (useDomains) {
|
if (useDomains) {
|
||||||
var domain = require('domain');
|
var domain = require('domain');
|
||||||
var gdom = domain.create();
|
const gdom = domain.create();
|
||||||
gdom.on('error', function(er) {
|
gdom.on('error', function(er) {
|
||||||
console.error('Error on global domain', er);
|
console.error('Error on global domain', er);
|
||||||
throw er;
|
throw er;
|
||||||
@ -22,19 +22,19 @@ if (useDomains) {
|
|||||||
|
|
||||||
module.exports = http.createServer(function(req, res) {
|
module.exports = http.createServer(function(req, res) {
|
||||||
if (useDomains) {
|
if (useDomains) {
|
||||||
var dom = domain.create();
|
const dom = domain.create();
|
||||||
dom.add(req);
|
dom.add(req);
|
||||||
dom.add(res);
|
dom.add(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
// URL format: /<type>/<length>/<chunks>/<responseBehavior>/chunkedEnc
|
// URL format: /<type>/<length>/<chunks>/<responseBehavior>/chunkedEnc
|
||||||
var params = req.url.split('/');
|
const params = req.url.split('/');
|
||||||
var command = params[1];
|
const command = params[1];
|
||||||
var body = '';
|
var body = '';
|
||||||
var arg = params[2];
|
const arg = params[2];
|
||||||
var n_chunks = parseInt(params[3], 10);
|
const n_chunks = parseInt(params[3], 10);
|
||||||
var resHow = (params.length >= 5 ? params[4] : 'normal');
|
const resHow = params.length >= 5 ? params[4] : 'normal';
|
||||||
var chunkedEnc = (params.length >= 6 && params[5] === 'false' ? false : true);
|
const chunkedEnc = params.length >= 6 && params[5] === 'false' ? false : true;
|
||||||
var status = 200;
|
var status = 200;
|
||||||
|
|
||||||
var n, i;
|
var n, i;
|
||||||
@ -96,7 +96,7 @@ module.exports = http.createServer(function(req, res) {
|
|||||||
|
|
||||||
// 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
|
||||||
var len = body.length;
|
const len = body.length;
|
||||||
switch (resHow) {
|
switch (resHow) {
|
||||||
case 'setHeader':
|
case 'setHeader':
|
||||||
res.statusCode = status;
|
res.statusCode = status;
|
||||||
@ -128,7 +128,7 @@ module.exports = http.createServer(function(req, res) {
|
|||||||
}
|
}
|
||||||
// send body in chunks
|
// send body in chunks
|
||||||
if (n_chunks > 1) {
|
if (n_chunks > 1) {
|
||||||
var step = Math.floor(len / n_chunks) || 1;
|
const step = Math.floor(len / n_chunks) || 1;
|
||||||
for (i = 0, n = (n_chunks - 1); i < n; ++i)
|
for (i = 0, n = (n_chunks - 1); i < n; ++i)
|
||||||
res.write(body.slice(i * step, i * step + step));
|
res.write(body.slice(i * step, i * step + step));
|
||||||
res.end(body.slice((n_chunks - 1) * step));
|
res.end(body.slice((n_chunks - 1) * step));
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
// test the throughput of the fs.WriteStream class.
|
// test the throughput of the fs.WriteStream class.
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var filename = path.resolve(__dirname, '.removeme-benchmark-garbage');
|
const filename = path.resolve(__dirname, '.removeme-benchmark-garbage');
|
||||||
var fs = require('fs');
|
const fs = require('fs');
|
||||||
var filesize = 1000 * 1024 * 1024;
|
const filesize = 1000 * 1024 * 1024;
|
||||||
var assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
var type, encoding, size;
|
var type, encoding, size;
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
type: ['buf', 'asc', 'utf'],
|
type: ['buf', 'asc', 'utf'],
|
||||||
size: [1024, 4096, 65535, 1024 * 1024]
|
size: [1024, 4096, 65535, 1024 * 1024]
|
||||||
});
|
});
|
||||||
@ -38,7 +38,7 @@ function main(conf) {
|
|||||||
|
|
||||||
function runTest() {
|
function runTest() {
|
||||||
assert(fs.statSync(filename).size === filesize);
|
assert(fs.statSync(filename).size === filesize);
|
||||||
var rs = fs.createReadStream(filename, {
|
const rs = fs.createReadStream(filename, {
|
||||||
highWaterMark: size,
|
highWaterMark: size,
|
||||||
encoding: encoding
|
encoding: encoding
|
||||||
});
|
});
|
||||||
@ -60,7 +60,7 @@ function runTest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function makeFile() {
|
function makeFile() {
|
||||||
var buf = Buffer.allocUnsafe(filesize / 1024);
|
const buf = Buffer.allocUnsafe(filesize / 1024);
|
||||||
if (encoding === 'utf8') {
|
if (encoding === 'utf8') {
|
||||||
// ü
|
// ü
|
||||||
for (var i = 0; i < buf.length; i++) {
|
for (var i = 0; i < buf.length; i++) {
|
||||||
@ -74,7 +74,7 @@ function makeFile() {
|
|||||||
|
|
||||||
try { fs.unlinkSync(filename); } catch (e) {}
|
try { fs.unlinkSync(filename); } catch (e) {}
|
||||||
var w = 1024;
|
var w = 1024;
|
||||||
var ws = fs.createWriteStream(filename);
|
const ws = fs.createWriteStream(filename);
|
||||||
ws.on('close', runTest);
|
ws.on('close', runTest);
|
||||||
ws.on('drain', write);
|
ws.on('drain', write);
|
||||||
write();
|
write();
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
n: [60e4]
|
n: [60e4]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = +conf.n;
|
const n = +conf.n;
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; ++i)
|
for (var i = 0; i < n; ++i)
|
||||||
|
@ -3,19 +3,19 @@
|
|||||||
// Yes, this is a silly benchmark. Most benchmarks are silly.
|
// Yes, this is a silly benchmark. Most benchmarks are silly.
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var filename = path.resolve(__dirname, '.removeme-benchmark-garbage');
|
const filename = path.resolve(__dirname, '.removeme-benchmark-garbage');
|
||||||
var fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
dur: [5],
|
dur: [5],
|
||||||
len: [1024, 16 * 1024 * 1024],
|
len: [1024, 16 * 1024 * 1024],
|
||||||
concurrent: [1, 10]
|
concurrent: [1, 10]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var len = +conf.len;
|
const len = +conf.len;
|
||||||
try { fs.unlinkSync(filename); } catch (e) {}
|
try { fs.unlinkSync(filename); } catch (e) {}
|
||||||
var data = Buffer.alloc(len, 'x');
|
var data = Buffer.alloc(len, 'x');
|
||||||
fs.writeFileSync(filename, data);
|
fs.writeFileSync(filename, data);
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
// test the throughput of the fs.WriteStream class.
|
// test the throughput of the fs.WriteStream class.
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var filename = path.resolve(__dirname, '.removeme-benchmark-garbage');
|
const filename = path.resolve(__dirname, '.removeme-benchmark-garbage');
|
||||||
var fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
dur: [5],
|
dur: [5],
|
||||||
type: ['buf', 'asc', 'utf'],
|
type: ['buf', 'asc', 'utf'],
|
||||||
size: [2, 1024, 65535, 1024 * 1024]
|
size: [2, 1024, 65535, 1024 * 1024]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var dur = +conf.dur;
|
const dur = +conf.dur;
|
||||||
var type = conf.type;
|
const type = conf.type;
|
||||||
var size = +conf.size;
|
const size = +conf.size;
|
||||||
var encoding;
|
var encoding;
|
||||||
|
|
||||||
var chunk;
|
var chunk;
|
||||||
@ -51,7 +51,7 @@ function main(conf) {
|
|||||||
f.on('close', done);
|
f.on('close', done);
|
||||||
f.on('finish', function() {
|
f.on('finish', function() {
|
||||||
ended = true;
|
ended = true;
|
||||||
var written = fs.statSync(filename).size / 1024;
|
const written = fs.statSync(filename).size / 1024;
|
||||||
try { fs.unlinkSync(filename); } catch (e) {}
|
try { fs.unlinkSync(filename); } catch (e) {}
|
||||||
bench.end(written / 1024);
|
bench.end(written / 1024);
|
||||||
});
|
});
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// test HTTP throughput in fragmented header case
|
// test HTTP throughput in fragmented header case
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var net = require('net');
|
const net = require('net');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
len: [1, 4, 8, 16, 32, 64, 128],
|
len: [1, 4, 8, 16, 32, 64, 128],
|
||||||
n: [5, 50, 500, 2000],
|
n: [5, 50, 500, 2000],
|
||||||
type: ['send'],
|
type: ['send'],
|
||||||
@ -12,10 +12,10 @@ var bench = common.createBenchmark(main, {
|
|||||||
|
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var len = +conf.len;
|
const len = +conf.len;
|
||||||
var num = +conf.n;
|
const num = +conf.n;
|
||||||
var todo = [];
|
var todo = [];
|
||||||
var headers = [];
|
const headers = [];
|
||||||
// Chose 7 because 9 showed "Connection error" / "Connection closed"
|
// Chose 7 because 9 showed "Connection error" / "Connection closed"
|
||||||
// An odd number could result in a better length dispersion.
|
// An odd number could result in a better length dispersion.
|
||||||
for (var i = 7; i <= 7 * 7 * 7; i *= 7)
|
for (var i = 7; i <= 7 * 7 * 7; i *= 7)
|
||||||
@ -42,20 +42,20 @@ function main(conf) {
|
|||||||
todo.push('');
|
todo.push('');
|
||||||
todo = todo.join('\r\n');
|
todo = todo.join('\r\n');
|
||||||
// Using odd numbers in many places may increase length coverage.
|
// Using odd numbers in many places may increase length coverage.
|
||||||
var chunksize = 37;
|
const chunksize = 37;
|
||||||
for (i = 0; i < todo.length; i += chunksize) {
|
for (i = 0; i < todo.length; i += chunksize) {
|
||||||
var cur = todo.slice(i, i + chunksize);
|
const cur = todo.slice(i, i + chunksize);
|
||||||
channel.write(cur);
|
channel.write(cur);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var min = 10;
|
const min = 10;
|
||||||
var size = 0;
|
var size = 0;
|
||||||
var mod = 317;
|
const mod = 317;
|
||||||
var mult = 17;
|
const mult = 17;
|
||||||
var add = 11;
|
const add = 11;
|
||||||
var count = 0;
|
var count = 0;
|
||||||
var PIPE = process.env.PIPE_NAME;
|
const PIPE = process.env.PIPE_NAME;
|
||||||
var socket = net.connect(PIPE, function() {
|
var socket = net.connect(PIPE, function() {
|
||||||
bench.start();
|
bench.start();
|
||||||
WriteHTTPHeaders(socket, 1, len);
|
WriteHTTPHeaders(socket, 1, len);
|
||||||
|
@ -31,8 +31,8 @@ const bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = +conf.n;
|
const n = +conf.n;
|
||||||
var key = conf.key;
|
const key = conf.key;
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
|
@ -41,8 +41,8 @@ const bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = +conf.n;
|
const n = +conf.n;
|
||||||
var key = conf.key;
|
const key = conf.key;
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
|
@ -8,9 +8,9 @@
|
|||||||
// Verify that our assumptions are valid.
|
// Verify that our assumptions are valid.
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
n: [1, 4, 8, 16],
|
n: [1, 4, 8, 16],
|
||||||
len: [1, 64, 256],
|
len: [1, 64, 256],
|
||||||
c: [100]
|
c: [100]
|
||||||
@ -18,9 +18,9 @@ var bench = common.createBenchmark(main, {
|
|||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
var chunk = Buffer.alloc(conf.len, '8');
|
const chunk = Buffer.alloc(conf.len, '8');
|
||||||
|
|
||||||
var server = http.createServer(function(req, res) {
|
const server = http.createServer(function(req, res) {
|
||||||
function send(left) {
|
function send(left) {
|
||||||
if (left === 0) return res.end();
|
if (left === 0) return res.end();
|
||||||
res.write(chunk);
|
res.write(chunk);
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
// Measure the time it takes for the HTTP client to send a request body.
|
// Measure the time it takes for the HTTP client to send a request body.
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var http = require('http');
|
const http = require('http');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
dur: [5],
|
dur: [5],
|
||||||
type: ['asc', 'utf', 'buf'],
|
type: ['asc', 'utf', 'buf'],
|
||||||
len: [32, 256, 1024],
|
len: [32, 256, 1024],
|
||||||
@ -12,8 +12,8 @@ var bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var dur = +conf.dur;
|
const dur = +conf.dur;
|
||||||
var len = +conf.len;
|
const len = +conf.len;
|
||||||
|
|
||||||
var encoding;
|
var encoding;
|
||||||
var chunk;
|
var chunk;
|
||||||
@ -31,7 +31,7 @@ function main(conf) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var nreqs = 0;
|
var nreqs = 0;
|
||||||
var options = {
|
const options = {
|
||||||
headers: { 'Connection': 'keep-alive', 'Transfer-Encoding': 'chunked' },
|
headers: { 'Connection': 'keep-alive', 'Transfer-Encoding': 'chunked' },
|
||||||
agent: new http.Agent({ maxSockets: 1 }),
|
agent: new http.Agent({ maxSockets: 1 }),
|
||||||
host: '127.0.0.1',
|
host: '127.0.0.1',
|
||||||
@ -40,7 +40,7 @@ function main(conf) {
|
|||||||
method: 'POST'
|
method: 'POST'
|
||||||
};
|
};
|
||||||
|
|
||||||
var server = http.createServer(function(req, res) {
|
const server = http.createServer(function(req, res) {
|
||||||
res.end();
|
res.end();
|
||||||
});
|
});
|
||||||
server.listen(options.port, options.host, function() {
|
server.listen(options.port, options.host, function() {
|
||||||
@ -50,7 +50,7 @@ function main(conf) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function pummel() {
|
function pummel() {
|
||||||
var req = http.request(options, function(res) {
|
const req = http.request(options, function(res) {
|
||||||
nreqs++;
|
nreqs++;
|
||||||
pummel(); // Line up next request.
|
pummel(); // Line up next request.
|
||||||
res.resume();
|
res.resume();
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var PORT = common.PORT;
|
const PORT = common.PORT;
|
||||||
|
|
||||||
var cluster = require('cluster');
|
const cluster = require('cluster');
|
||||||
if (cluster.isMaster) {
|
if (cluster.isMaster) {
|
||||||
var bench = common.createBenchmark(main, {
|
var bench = common.createBenchmark(main, {
|
||||||
// unicode confuses ab on os x.
|
// unicode confuses ab on os x.
|
||||||
@ -11,15 +11,15 @@ if (cluster.isMaster) {
|
|||||||
c: [50, 500]
|
c: [50, 500]
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var port = parseInt(process.env.PORT || PORT);
|
const port = parseInt(process.env.PORT || PORT);
|
||||||
require('../fixtures/simple-http-server.js').listen(port);
|
require('../fixtures/simple-http-server.js').listen(port);
|
||||||
}
|
}
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
process.env.PORT = PORT;
|
process.env.PORT = PORT;
|
||||||
var workers = 0;
|
var workers = 0;
|
||||||
var w1 = cluster.fork();
|
const w1 = cluster.fork();
|
||||||
var w2 = cluster.fork();
|
const w2 = cluster.fork();
|
||||||
|
|
||||||
cluster.on('listening', function() {
|
cluster.on('listening', function() {
|
||||||
workers++;
|
workers++;
|
||||||
@ -27,7 +27,7 @@ function main(conf) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
var path = `/${conf.type}/${conf.len}`;
|
const path = `/${conf.type}/${conf.len}`;
|
||||||
|
|
||||||
bench.http({
|
bench.http({
|
||||||
path: path,
|
path: path,
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var ClientRequest = require('http').ClientRequest;
|
const ClientRequest = require('http').ClientRequest;
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
len: [1, 8, 16, 32, 64, 128],
|
len: [1, 8, 16, 32, 64, 128],
|
||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var len = +conf.len;
|
const len = +conf.len;
|
||||||
var n = +conf.n;
|
const n = +conf.n;
|
||||||
|
|
||||||
var path = '/'.repeat(len);
|
const path = '/'.repeat(len);
|
||||||
var opts = { path: path, createConnection: function() {} };
|
const opts = { path: path, createConnection: function() {} };
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
|
@ -8,9 +8,9 @@
|
|||||||
// Verify that our assumptions are valid.
|
// Verify that our assumptions are valid.
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
type: ['asc', 'utf', 'buf'],
|
type: ['asc', 'utf', 'buf'],
|
||||||
len: [64 * 1024, 128 * 1024, 256 * 1024, 1024 * 1024],
|
len: [64 * 1024, 128 * 1024, 256 * 1024, 1024 * 1024],
|
||||||
c: [100],
|
c: [100],
|
||||||
@ -20,7 +20,7 @@ var bench = common.createBenchmark(main, {
|
|||||||
function main(conf) {
|
function main(conf) {
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
var chunk;
|
var chunk;
|
||||||
var len = conf.len;
|
const len = conf.len;
|
||||||
switch (conf.type) {
|
switch (conf.type) {
|
||||||
case 'buf':
|
case 'buf':
|
||||||
chunk = Buffer.alloc(len, 'x');
|
chunk = Buffer.alloc(len, 'x');
|
||||||
@ -42,9 +42,9 @@ function main(conf) {
|
|||||||
res.end(chunk);
|
res.end(chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
var method = conf.method === 'write' ? write : end;
|
const method = conf.method === 'write' ? write : end;
|
||||||
|
|
||||||
var server = http.createServer(function(req, res) {
|
const server = http.createServer(function(req, res) {
|
||||||
method(res);
|
method(res);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var assert = require('assert');
|
const assert = require('assert');
|
||||||
var http = require('http');
|
const http = require('http');
|
||||||
var fs = require('fs');
|
const fs = require('fs');
|
||||||
var { fork } = require('child_process');
|
const { fork } = require('child_process');
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
const { PIPE, tmpDir } = require('../../test/common');
|
const { PIPE, tmpDir } = require('../../test/common');
|
||||||
process.env.PIPE_NAME = PIPE;
|
process.env.PIPE_NAME = PIPE;
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ try {
|
|||||||
} catch (e) { /* ignore */ }
|
} catch (e) { /* ignore */ }
|
||||||
|
|
||||||
server = http.createServer(function(req, res) {
|
server = http.createServer(function(req, res) {
|
||||||
var headers = {
|
const headers = {
|
||||||
'content-type': 'text/plain',
|
'content-type': 'text/plain',
|
||||||
'content-length': '2'
|
'content-length': '2'
|
||||||
};
|
};
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var PORT = common.PORT;
|
const PORT = common.PORT;
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
// unicode confuses ab on os x.
|
// unicode confuses ab on os x.
|
||||||
type: ['bytes', 'buffer'],
|
type: ['bytes', 'buffer'],
|
||||||
len: [4, 1024, 102400],
|
len: [4, 1024, 102400],
|
||||||
@ -17,7 +17,7 @@ function main(conf) {
|
|||||||
var server = require('../fixtures/simple-http-server.js')
|
var server = require('../fixtures/simple-http-server.js')
|
||||||
.listen(process.env.PORT || common.PORT)
|
.listen(process.env.PORT || common.PORT)
|
||||||
.on('listening', function() {
|
.on('listening', function() {
|
||||||
var path =
|
const path =
|
||||||
`/${conf.type}/${conf.len}/${conf.chunks}/${conf.res}/${conf.chunkedEnc}`;
|
`/${conf.type}/${conf.len}/${conf.chunks}/${conf.res}/${conf.chunkedEnc}`;
|
||||||
|
|
||||||
bench.http({
|
bench.http({
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
const common = require('../common.js');
|
const common = require('../common.js');
|
||||||
const PORT = common.PORT;
|
const PORT = common.PORT;
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
n: [1e3],
|
n: [1e3],
|
||||||
nheaders: [0, 10, 100, 1000],
|
nheaders: [0, 10, 100, 1000],
|
||||||
}, { flags: ['--expose-http2', '--no-warnings'] });
|
}, { flags: ['--expose-http2', '--no-warnings'] });
|
||||||
|
@ -7,7 +7,7 @@ const fs = require('fs');
|
|||||||
|
|
||||||
const file = path.join(path.resolve(__dirname, '../fixtures'), 'alice.html');
|
const file = path.join(path.resolve(__dirname, '../fixtures'), 'alice.html');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
requests: [100, 1000, 10000, 100000, 1000000],
|
requests: [100, 1000, 10000, 100000, 1000000],
|
||||||
streams: [100, 200, 1000],
|
streams: [100, 200, 1000],
|
||||||
clients: [1, 2]
|
clients: [1, 2]
|
||||||
|
@ -8,7 +8,7 @@ const fs = require('fs');
|
|||||||
|
|
||||||
const file = path.join(path.resolve(__dirname, '../fixtures'), 'alice.html');
|
const file = path.join(path.resolve(__dirname, '../fixtures'), 'alice.html');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
requests: [100, 1000, 10000, 100000],
|
requests: [100, 1000, 10000, 100000],
|
||||||
streams: [100, 200, 1000],
|
streams: [100, 200, 1000],
|
||||||
clients: [1, 2]
|
clients: [1, 2]
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
const common = require('../common.js');
|
const common = require('../common.js');
|
||||||
const PORT = common.PORT;
|
const PORT = common.PORT;
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
streams: [100, 200, 1000],
|
streams: [100, 200, 1000],
|
||||||
length: [64 * 1024, 128 * 1024, 256 * 1024, 1024 * 1024],
|
length: [64 * 1024, 128 * 1024, 256 * 1024, 1024 * 1024],
|
||||||
}, { flags: ['--expose-http2', '--no-warnings'] });
|
}, { flags: ['--expose-http2', '--no-warnings'] });
|
||||||
|
@ -12,7 +12,7 @@ const methods = [
|
|||||||
'restAndConcat'
|
'restAndConcat'
|
||||||
];
|
];
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
method: methods,
|
method: methods,
|
||||||
concat: [1, 0],
|
concat: [1, 0],
|
||||||
n: [1000000]
|
n: [1000000]
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
n: [100000]
|
n: [100000]
|
||||||
}, {
|
}, {
|
||||||
flags: ['--expose-internals']
|
flags: ['--expose-internals']
|
||||||
@ -10,12 +10,12 @@ var bench = common.createBenchmark(main, {
|
|||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
const FreeList = require('internal/freelist');
|
const FreeList = require('internal/freelist');
|
||||||
var n = conf.n;
|
const n = conf.n;
|
||||||
var poolSize = 1000;
|
const poolSize = 1000;
|
||||||
var list = new FreeList('test', poolSize, Object);
|
const list = new FreeList('test', poolSize, Object);
|
||||||
var i;
|
var i;
|
||||||
var j;
|
var j;
|
||||||
var used = [];
|
const used = [];
|
||||||
|
|
||||||
// First, alloc `poolSize` items
|
// First, alloc `poolSize` items
|
||||||
for (j = 0; j < poolSize; j++) {
|
for (j = 0; j < poolSize; j++) {
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
// Note that JS speed goes up, while cxx speed stays about the same.
|
// Note that JS speed goes up, while cxx speed stays about the same.
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var assert = require('assert');
|
const assert = require('assert');
|
||||||
var common = require('../../common.js');
|
const common = require('../../common.js');
|
||||||
|
|
||||||
// this fails when we try to open with a different version of node,
|
// this fails when we try to open with a different version of node,
|
||||||
// which is quite common for benchmarks. so in that case, just
|
// which is quite common for benchmarks. so in that case, just
|
||||||
@ -17,7 +17,7 @@ try {
|
|||||||
console.error('misc/function_call.js Binding failed to load');
|
console.error('misc/function_call.js Binding failed to load');
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
var cxx = binding.hello;
|
const cxx = binding.hello;
|
||||||
|
|
||||||
var c = 0;
|
var c = 0;
|
||||||
function js() {
|
function js() {
|
||||||
@ -26,15 +26,15 @@ function js() {
|
|||||||
|
|
||||||
assert(js() === cxx());
|
assert(js() === cxx());
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
type: ['js', 'cxx'],
|
type: ['js', 'cxx'],
|
||||||
millions: [1, 10, 50]
|
millions: [1, 10, 50]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = +conf.millions * 1e6;
|
const n = +conf.millions * 1e6;
|
||||||
|
|
||||||
var fn = conf.type === 'cxx' ? cxx : js;
|
const fn = conf.type === 'cxx' ? cxx : js;
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
fn();
|
fn();
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var spawn = require('child_process').spawn;
|
const spawn = require('child_process').spawn;
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
var emptyJsFile = path.resolve(__dirname, '../../test/fixtures/semicolon.js');
|
const emptyJsFile = path.resolve(__dirname, '../../test/fixtures/semicolon.js');
|
||||||
|
|
||||||
var bench = common.createBenchmark(startNode, {
|
const bench = common.createBenchmark(startNode, {
|
||||||
dur: [1]
|
dur: [1]
|
||||||
});
|
});
|
||||||
|
|
||||||
function startNode(conf) {
|
function startNode(conf) {
|
||||||
var dur = +conf.dur;
|
const dur = +conf.dur;
|
||||||
var go = true;
|
var go = true;
|
||||||
var starts = 0;
|
var starts = 0;
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ function startNode(conf) {
|
|||||||
start();
|
start();
|
||||||
|
|
||||||
function start() {
|
function start() {
|
||||||
var node = spawn(process.execPath || process.argv[0], [emptyJsFile]);
|
const node = spawn(process.execPath || process.argv[0], [emptyJsFile]);
|
||||||
node.on('exit', function(exitCode) {
|
node.on('exit', function(exitCode) {
|
||||||
if (exitCode !== 0) {
|
if (exitCode !== 0) {
|
||||||
throw new Error('Error during node startup');
|
throw new Error('Error during node startup');
|
||||||
|
@ -23,7 +23,7 @@ function main(conf) {
|
|||||||
for (var i = 0; i < conf.type.length * 10; i += 1)
|
for (var i = 0; i < conf.type.length * 10; i += 1)
|
||||||
fn({}, process.env);
|
fn({}, process.env);
|
||||||
|
|
||||||
var obj = new Proxy({}, { set: function(a, b, c) { return true; } });
|
const obj = new Proxy({}, { set: function(a, b, c) { return true; } });
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var j = 0; j < n; j += 1)
|
for (var j = 0; j < n; j += 1)
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
// compare with "google-chrome deps/v8/benchmarks/run.html"
|
// compare with "google-chrome deps/v8/benchmarks/run.html"
|
||||||
'use strict';
|
'use strict';
|
||||||
var fs = require('fs');
|
const fs = require('fs');
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
var vm = require('vm');
|
const vm = require('vm');
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
|
|
||||||
var dir = path.join(__dirname, '..', '..', 'deps', 'v8', 'benchmarks');
|
const dir = path.join(__dirname, '..', '..', 'deps', 'v8', 'benchmarks');
|
||||||
|
|
||||||
function load(filename, inGlobal) {
|
function load(filename, inGlobal) {
|
||||||
var source = fs.readFileSync(path.join(dir, filename), 'utf8');
|
var source = fs.readFileSync(path.join(dir, filename), 'utf8');
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var fs = require('fs');
|
const fs = require('fs');
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
|
|
||||||
var tmpDirectory = path.join(__dirname, '..', 'tmp');
|
const tmpDirectory = path.join(__dirname, '..', 'tmp');
|
||||||
var benchmarkDirectory = path.join(tmpDirectory, 'nodejs-benchmark-module');
|
const benchmarkDirectory = path.join(tmpDirectory, 'nodejs-benchmark-module');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
thousands: [50],
|
thousands: [50],
|
||||||
fullPath: ['true', 'false'],
|
fullPath: ['true', 'false'],
|
||||||
useCache: ['true', 'false']
|
useCache: ['true', 'false']
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = +conf.thousands * 1e3;
|
const n = +conf.thousands * 1e3;
|
||||||
|
|
||||||
rmrf(tmpDirectory);
|
rmrf(tmpDirectory);
|
||||||
try { fs.mkdirSync(tmpDirectory); } catch (e) {}
|
try { fs.mkdirSync(tmpDirectory); } catch (e) {}
|
||||||
@ -69,7 +69,7 @@ function measureDir(n, useCache) {
|
|||||||
|
|
||||||
function rmrf(location) {
|
function rmrf(location) {
|
||||||
try {
|
try {
|
||||||
var things = fs.readdirSync(location);
|
const things = fs.readdirSync(location);
|
||||||
things.forEach(function(thing) {
|
things.forEach(function(thing) {
|
||||||
var cur = path.join(location, thing),
|
var cur = path.join(location, thing),
|
||||||
isDirectory = fs.statSync(cur).isDirectory();
|
isDirectory = fs.statSync(cur).isDirectory();
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
// test the speed of .pipe() with sockets
|
// test the speed of .pipe() with sockets
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var PORT = common.PORT;
|
const PORT = common.PORT;
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
len: [4, 8, 16, 32, 64, 128, 512, 1024],
|
len: [4, 8, 16, 32, 64, 128, 512, 1024],
|
||||||
type: ['buf'],
|
type: ['buf'],
|
||||||
dur: [5],
|
dur: [5],
|
||||||
@ -40,7 +40,7 @@ function main(conf) {
|
|||||||
server();
|
server();
|
||||||
}
|
}
|
||||||
|
|
||||||
var net = require('net');
|
const net = require('net');
|
||||||
|
|
||||||
function Writer() {
|
function Writer() {
|
||||||
this.received = 0;
|
this.received = 0;
|
||||||
@ -65,15 +65,15 @@ Writer.prototype.emit = function() {};
|
|||||||
Writer.prototype.prependListener = function() {};
|
Writer.prototype.prependListener = function() {};
|
||||||
|
|
||||||
function server() {
|
function server() {
|
||||||
var writer = new Writer();
|
const writer = new Writer();
|
||||||
|
|
||||||
// the actual benchmark.
|
// the actual benchmark.
|
||||||
var server = net.createServer(function(socket) {
|
const server = net.createServer(function(socket) {
|
||||||
socket.pipe(writer);
|
socket.pipe(writer);
|
||||||
});
|
});
|
||||||
|
|
||||||
server.listen(PORT, function() {
|
server.listen(PORT, function() {
|
||||||
var socket = net.connect(PORT);
|
const socket = net.connect(PORT);
|
||||||
socket.on('connect', function() {
|
socket.on('connect', function() {
|
||||||
bench.start();
|
bench.start();
|
||||||
|
|
||||||
@ -81,8 +81,8 @@ function server() {
|
|||||||
send();
|
send();
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
var bytes = writer.received;
|
const bytes = writer.received;
|
||||||
var gbits = (bytes * 8) / (1024 * 1024 * 1024);
|
const gbits = (bytes * 8) / (1024 * 1024 * 1024);
|
||||||
bench.end(gbits);
|
bench.end(gbits);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}, dur * 1000);
|
}, dur * 1000);
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
// test the speed of .pipe() with sockets
|
// test the speed of .pipe() with sockets
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var PORT = common.PORT;
|
const PORT = common.PORT;
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
len: [102400, 1024 * 1024 * 16],
|
len: [102400, 1024 * 1024 * 16],
|
||||||
type: ['utf', 'asc', 'buf'],
|
type: ['utf', 'asc', 'buf'],
|
||||||
dur: [5],
|
dur: [5],
|
||||||
@ -40,7 +40,7 @@ function main(conf) {
|
|||||||
server();
|
server();
|
||||||
}
|
}
|
||||||
|
|
||||||
var net = require('net');
|
const net = require('net');
|
||||||
|
|
||||||
function Writer() {
|
function Writer() {
|
||||||
this.received = 0;
|
this.received = 0;
|
||||||
@ -66,8 +66,8 @@ Writer.prototype.prependListener = function() {};
|
|||||||
|
|
||||||
|
|
||||||
function flow() {
|
function flow() {
|
||||||
var dest = this.dest;
|
const dest = this.dest;
|
||||||
var res = dest.write(chunk, encoding);
|
const res = dest.write(chunk, encoding);
|
||||||
if (!res)
|
if (!res)
|
||||||
dest.once('drain', this.flow);
|
dest.once('drain', this.flow);
|
||||||
else
|
else
|
||||||
@ -87,24 +87,24 @@ Reader.prototype.pipe = function(dest) {
|
|||||||
|
|
||||||
|
|
||||||
function server() {
|
function server() {
|
||||||
var reader = new Reader();
|
const reader = new Reader();
|
||||||
var writer = new Writer();
|
const writer = new Writer();
|
||||||
|
|
||||||
// the actual benchmark.
|
// the actual benchmark.
|
||||||
var server = net.createServer(function(socket) {
|
const server = net.createServer(function(socket) {
|
||||||
socket.pipe(writer);
|
socket.pipe(writer);
|
||||||
});
|
});
|
||||||
|
|
||||||
server.listen(PORT, function() {
|
server.listen(PORT, function() {
|
||||||
var socket = net.connect(PORT);
|
const socket = net.connect(PORT);
|
||||||
socket.on('connect', function() {
|
socket.on('connect', function() {
|
||||||
bench.start();
|
bench.start();
|
||||||
|
|
||||||
reader.pipe(socket);
|
reader.pipe(socket);
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
var bytes = writer.received;
|
const bytes = writer.received;
|
||||||
var gbits = (bytes * 8) / (1024 * 1024 * 1024);
|
const gbits = (bytes * 8) / (1024 * 1024 * 1024);
|
||||||
bench.end(gbits);
|
bench.end(gbits);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}, dur * 1000);
|
}, dur * 1000);
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
// test the speed of .pipe() with sockets
|
// test the speed of .pipe() with sockets
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var PORT = common.PORT;
|
const PORT = common.PORT;
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
len: [102400, 1024 * 1024 * 16],
|
len: [102400, 1024 * 1024 * 16],
|
||||||
type: ['utf', 'asc', 'buf'],
|
type: ['utf', 'asc', 'buf'],
|
||||||
dur: [5],
|
dur: [5],
|
||||||
@ -40,7 +40,7 @@ function main(conf) {
|
|||||||
server();
|
server();
|
||||||
}
|
}
|
||||||
|
|
||||||
var net = require('net');
|
const net = require('net');
|
||||||
|
|
||||||
function Writer() {
|
function Writer() {
|
||||||
this.received = 0;
|
this.received = 0;
|
||||||
@ -66,8 +66,8 @@ Writer.prototype.prependListener = function() {};
|
|||||||
|
|
||||||
|
|
||||||
function flow() {
|
function flow() {
|
||||||
var dest = this.dest;
|
const dest = this.dest;
|
||||||
var res = dest.write(chunk, encoding);
|
const res = dest.write(chunk, encoding);
|
||||||
if (!res)
|
if (!res)
|
||||||
dest.once('drain', this.flow);
|
dest.once('drain', this.flow);
|
||||||
else
|
else
|
||||||
@ -87,16 +87,16 @@ Reader.prototype.pipe = function(dest) {
|
|||||||
|
|
||||||
|
|
||||||
function server() {
|
function server() {
|
||||||
var reader = new Reader();
|
const reader = new Reader();
|
||||||
var writer = new Writer();
|
const writer = new Writer();
|
||||||
|
|
||||||
// the actual benchmark.
|
// the actual benchmark.
|
||||||
var server = net.createServer(function(socket) {
|
const server = net.createServer(function(socket) {
|
||||||
socket.pipe(socket);
|
socket.pipe(socket);
|
||||||
});
|
});
|
||||||
|
|
||||||
server.listen(PORT, function() {
|
server.listen(PORT, function() {
|
||||||
var socket = net.connect(PORT);
|
const socket = net.connect(PORT);
|
||||||
socket.on('connect', function() {
|
socket.on('connect', function() {
|
||||||
bench.start();
|
bench.start();
|
||||||
|
|
||||||
@ -106,8 +106,8 @@ function server() {
|
|||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
// 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.
|
||||||
var bytes = writer.received * 2;
|
const bytes = writer.received * 2;
|
||||||
var gbits = (bytes * 8) / (1024 * 1024 * 1024);
|
const gbits = (bytes * 8) / (1024 * 1024 * 1024);
|
||||||
bench.end(gbits);
|
bench.end(gbits);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}, dur * 1000);
|
}, dur * 1000);
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
// test the speed of .pipe() with sockets
|
// test the speed of .pipe() with sockets
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var PORT = common.PORT;
|
const PORT = common.PORT;
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
len: [102400, 1024 * 1024 * 16],
|
len: [102400, 1024 * 1024 * 16],
|
||||||
type: ['utf', 'asc', 'buf'],
|
type: ['utf', 'asc', 'buf'],
|
||||||
dur: [5]
|
dur: [5]
|
||||||
@ -40,7 +40,7 @@ function main(conf) {
|
|||||||
server();
|
server();
|
||||||
}
|
}
|
||||||
|
|
||||||
var net = require('net');
|
const net = require('net');
|
||||||
|
|
||||||
function Writer() {
|
function Writer() {
|
||||||
this.received = 0;
|
this.received = 0;
|
||||||
@ -66,8 +66,8 @@ Writer.prototype.prependListener = function() {};
|
|||||||
|
|
||||||
|
|
||||||
function flow() {
|
function flow() {
|
||||||
var dest = this.dest;
|
const dest = this.dest;
|
||||||
var res = dest.write(chunk, encoding);
|
const res = dest.write(chunk, encoding);
|
||||||
if (!res)
|
if (!res)
|
||||||
dest.once('drain', this.flow);
|
dest.once('drain', this.flow);
|
||||||
else
|
else
|
||||||
@ -87,24 +87,24 @@ Reader.prototype.pipe = function(dest) {
|
|||||||
|
|
||||||
|
|
||||||
function server() {
|
function server() {
|
||||||
var reader = new Reader();
|
const reader = new Reader();
|
||||||
var writer = new Writer();
|
const writer = new Writer();
|
||||||
|
|
||||||
// the actual benchmark.
|
// the actual benchmark.
|
||||||
var server = net.createServer(function(socket) {
|
const server = net.createServer(function(socket) {
|
||||||
reader.pipe(socket);
|
reader.pipe(socket);
|
||||||
});
|
});
|
||||||
|
|
||||||
server.listen(PORT, function() {
|
server.listen(PORT, function() {
|
||||||
var socket = net.connect(PORT);
|
const socket = net.connect(PORT);
|
||||||
socket.on('connect', function() {
|
socket.on('connect', function() {
|
||||||
bench.start();
|
bench.start();
|
||||||
|
|
||||||
socket.pipe(writer);
|
socket.pipe(writer);
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
var bytes = writer.received;
|
const bytes = writer.received;
|
||||||
var gbits = (bytes * 8) / (1024 * 1024 * 1024);
|
const gbits = (bytes * 8) / (1024 * 1024 * 1024);
|
||||||
bench.end(gbits);
|
bench.end(gbits);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}, dur * 1000);
|
}, dur * 1000);
|
||||||
|
@ -2,22 +2,22 @@
|
|||||||
// as many bytes as we can in the specified time (default = 10s)
|
// as many bytes as we can in the specified time (default = 10s)
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var util = require('util');
|
const util = require('util');
|
||||||
|
|
||||||
// if there are --dur=N and --len=N args, then
|
// if there are --dur=N and --len=N args, then
|
||||||
// run the function with those settings.
|
// run the function with those settings.
|
||||||
// if not, then queue up a bunch of child processes.
|
// if not, then queue up a bunch of child processes.
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
len: [102400, 1024 * 1024 * 16],
|
len: [102400, 1024 * 1024 * 16],
|
||||||
type: ['utf', 'asc', 'buf'],
|
type: ['utf', 'asc', 'buf'],
|
||||||
dur: [5]
|
dur: [5]
|
||||||
});
|
});
|
||||||
|
|
||||||
var TCP = process.binding('tcp_wrap').TCP;
|
const TCP = process.binding('tcp_wrap').TCP;
|
||||||
var TCPConnectWrap = process.binding('tcp_wrap').TCPConnectWrap;
|
const TCPConnectWrap = process.binding('tcp_wrap').TCPConnectWrap;
|
||||||
var WriteWrap = process.binding('stream_wrap').WriteWrap;
|
const WriteWrap = process.binding('stream_wrap').WriteWrap;
|
||||||
var PORT = common.PORT;
|
const PORT = common.PORT;
|
||||||
|
|
||||||
var dur;
|
var dur;
|
||||||
var len;
|
var len;
|
||||||
@ -36,7 +36,7 @@ function fail(err, syscall) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function server() {
|
function server() {
|
||||||
var serverHandle = new TCP();
|
const serverHandle = new TCP();
|
||||||
var err = serverHandle.bind('127.0.0.1', PORT);
|
var err = serverHandle.bind('127.0.0.1', PORT);
|
||||||
if (err)
|
if (err)
|
||||||
fail(err, 'bind');
|
fail(err, 'bind');
|
||||||
@ -92,9 +92,9 @@ function client() {
|
|||||||
throw new Error(`invalid type: ${type}`);
|
throw new Error(`invalid type: ${type}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
var clientHandle = new TCP();
|
const clientHandle = new TCP();
|
||||||
var connectReq = new TCPConnectWrap();
|
const connectReq = new TCPConnectWrap();
|
||||||
var err = clientHandle.connect(connectReq, '127.0.0.1', PORT);
|
const err = clientHandle.connect(connectReq, '127.0.0.1', PORT);
|
||||||
|
|
||||||
if (err)
|
if (err)
|
||||||
fail(err, 'connect');
|
fail(err, 'connect');
|
||||||
@ -110,7 +110,7 @@ function client() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function write() {
|
function write() {
|
||||||
var writeReq = new WriteWrap();
|
const writeReq = new WriteWrap();
|
||||||
writeReq.oncomplete = afterWrite;
|
writeReq.oncomplete = afterWrite;
|
||||||
var err;
|
var err;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -2,22 +2,22 @@
|
|||||||
// as many bytes as we can in the specified time (default = 10s)
|
// as many bytes as we can in the specified time (default = 10s)
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var util = require('util');
|
const util = require('util');
|
||||||
|
|
||||||
// if there are --dur=N and --len=N args, then
|
// if there are --dur=N and --len=N args, then
|
||||||
// run the function with those settings.
|
// run the function with those settings.
|
||||||
// if not, then queue up a bunch of child processes.
|
// if not, then queue up a bunch of child processes.
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
len: [102400, 1024 * 1024 * 16],
|
len: [102400, 1024 * 1024 * 16],
|
||||||
type: ['utf', 'asc', 'buf'],
|
type: ['utf', 'asc', 'buf'],
|
||||||
dur: [5]
|
dur: [5]
|
||||||
});
|
});
|
||||||
|
|
||||||
var TCP = process.binding('tcp_wrap').TCP;
|
const TCP = process.binding('tcp_wrap').TCP;
|
||||||
var TCPConnectWrap = process.binding('tcp_wrap').TCPConnectWrap;
|
const TCPConnectWrap = process.binding('tcp_wrap').TCPConnectWrap;
|
||||||
var WriteWrap = process.binding('stream_wrap').WriteWrap;
|
const WriteWrap = process.binding('stream_wrap').WriteWrap;
|
||||||
var PORT = common.PORT;
|
const PORT = common.PORT;
|
||||||
|
|
||||||
var dur;
|
var dur;
|
||||||
var len;
|
var len;
|
||||||
@ -35,7 +35,7 @@ function fail(err, syscall) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function server() {
|
function server() {
|
||||||
var serverHandle = new TCP();
|
const serverHandle = new TCP();
|
||||||
var err = serverHandle.bind('127.0.0.1', PORT);
|
var err = serverHandle.bind('127.0.0.1', PORT);
|
||||||
if (err)
|
if (err)
|
||||||
fail(err, 'bind');
|
fail(err, 'bind');
|
||||||
@ -54,7 +54,7 @@ function server() {
|
|||||||
if (nread < 0)
|
if (nread < 0)
|
||||||
fail(nread, 'read');
|
fail(nread, 'read');
|
||||||
|
|
||||||
var writeReq = new WriteWrap();
|
const writeReq = new WriteWrap();
|
||||||
writeReq.async = false;
|
writeReq.async = false;
|
||||||
err = clientHandle.writeBuffer(writeReq, buffer);
|
err = clientHandle.writeBuffer(writeReq, buffer);
|
||||||
|
|
||||||
@ -89,9 +89,9 @@ function client() {
|
|||||||
throw new Error(`invalid type: ${type}`);
|
throw new Error(`invalid type: ${type}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
var clientHandle = new TCP();
|
const clientHandle = new TCP();
|
||||||
var connectReq = new TCPConnectWrap();
|
const connectReq = new TCPConnectWrap();
|
||||||
var err = clientHandle.connect(connectReq, '127.0.0.1', PORT);
|
const err = clientHandle.connect(connectReq, '127.0.0.1', PORT);
|
||||||
var bytes = 0;
|
var bytes = 0;
|
||||||
|
|
||||||
if (err)
|
if (err)
|
||||||
@ -124,7 +124,7 @@ function client() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function write() {
|
function write() {
|
||||||
var writeReq = new WriteWrap();
|
const writeReq = new WriteWrap();
|
||||||
writeReq.oncomplete = afterWrite;
|
writeReq.oncomplete = afterWrite;
|
||||||
var err;
|
var err;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -2,22 +2,22 @@
|
|||||||
// as many bytes as we can in the specified time (default = 10s)
|
// as many bytes as we can in the specified time (default = 10s)
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var util = require('util');
|
const util = require('util');
|
||||||
|
|
||||||
// if there are dur=N and len=N args, then
|
// if there are dur=N and len=N args, then
|
||||||
// run the function with those settings.
|
// run the function with those settings.
|
||||||
// if not, then queue up a bunch of child processes.
|
// if not, then queue up a bunch of child processes.
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
len: [102400, 1024 * 1024 * 16],
|
len: [102400, 1024 * 1024 * 16],
|
||||||
type: ['utf', 'asc', 'buf'],
|
type: ['utf', 'asc', 'buf'],
|
||||||
dur: [5]
|
dur: [5]
|
||||||
});
|
});
|
||||||
|
|
||||||
var TCP = process.binding('tcp_wrap').TCP;
|
const TCP = process.binding('tcp_wrap').TCP;
|
||||||
var TCPConnectWrap = process.binding('tcp_wrap').TCPConnectWrap;
|
const TCPConnectWrap = process.binding('tcp_wrap').TCPConnectWrap;
|
||||||
var WriteWrap = process.binding('stream_wrap').WriteWrap;
|
const WriteWrap = process.binding('stream_wrap').WriteWrap;
|
||||||
var PORT = common.PORT;
|
const PORT = common.PORT;
|
||||||
|
|
||||||
var dur;
|
var dur;
|
||||||
var len;
|
var len;
|
||||||
@ -35,7 +35,7 @@ function fail(err, syscall) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function server() {
|
function server() {
|
||||||
var serverHandle = new TCP();
|
const serverHandle = new TCP();
|
||||||
var err = serverHandle.bind('127.0.0.1', PORT);
|
var err = serverHandle.bind('127.0.0.1', PORT);
|
||||||
if (err)
|
if (err)
|
||||||
fail(err, 'bind');
|
fail(err, 'bind');
|
||||||
@ -69,7 +69,7 @@ function server() {
|
|||||||
write();
|
write();
|
||||||
|
|
||||||
function write() {
|
function write() {
|
||||||
var writeReq = new WriteWrap();
|
const writeReq = new WriteWrap();
|
||||||
writeReq.async = false;
|
writeReq.async = false;
|
||||||
writeReq.oncomplete = afterWrite;
|
writeReq.oncomplete = afterWrite;
|
||||||
var err;
|
var err;
|
||||||
@ -107,9 +107,9 @@ function server() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function client() {
|
function client() {
|
||||||
var clientHandle = new TCP();
|
const clientHandle = new TCP();
|
||||||
var connectReq = new TCPConnectWrap();
|
const connectReq = new TCPConnectWrap();
|
||||||
var err = clientHandle.connect(connectReq, '127.0.0.1', PORT);
|
const err = clientHandle.connect(connectReq, '127.0.0.1', PORT);
|
||||||
|
|
||||||
if (err)
|
if (err)
|
||||||
fail(err, 'connect');
|
fail(err, 'connect');
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
pathext: [
|
pathext: [
|
||||||
'',
|
'',
|
||||||
'/',
|
'/',
|
||||||
@ -19,11 +19,11 @@ var bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = +conf.n;
|
const n = +conf.n;
|
||||||
var p = path.posix;
|
const p = path.posix;
|
||||||
var input = String(conf.pathext);
|
var input = String(conf.pathext);
|
||||||
var ext;
|
var ext;
|
||||||
var extIdx = input.indexOf('|');
|
const extIdx = input.indexOf('|');
|
||||||
if (extIdx !== -1) {
|
if (extIdx !== -1) {
|
||||||
ext = input.slice(extIdx + 1);
|
ext = input.slice(extIdx + 1);
|
||||||
input = input.slice(0, extIdx);
|
input = input.slice(0, extIdx);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
pathext: [
|
pathext: [
|
||||||
'',
|
'',
|
||||||
'C:\\',
|
'C:\\',
|
||||||
@ -19,11 +19,11 @@ var bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = +conf.n;
|
const n = +conf.n;
|
||||||
var p = path.win32;
|
const p = path.win32;
|
||||||
var input = String(conf.pathext);
|
var input = String(conf.pathext);
|
||||||
var ext;
|
var ext;
|
||||||
var extIdx = input.indexOf('|');
|
const extIdx = input.indexOf('|');
|
||||||
if (extIdx !== -1) {
|
if (extIdx !== -1) {
|
||||||
ext = input.slice(extIdx + 1);
|
ext = input.slice(extIdx + 1);
|
||||||
input = input.slice(0, extIdx);
|
input = input.slice(0, extIdx);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
path: [
|
path: [
|
||||||
'',
|
'',
|
||||||
'/',
|
'/',
|
||||||
@ -16,9 +16,9 @@ var bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = +conf.n;
|
const n = +conf.n;
|
||||||
var p = path.posix;
|
const p = path.posix;
|
||||||
var input = String(conf.path);
|
const input = String(conf.path);
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
path: [
|
path: [
|
||||||
'',
|
'',
|
||||||
'\\',
|
'\\',
|
||||||
@ -16,9 +16,9 @@ var bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = +conf.n;
|
const n = +conf.n;
|
||||||
var p = path.win32;
|
const p = path.win32;
|
||||||
var input = String(conf.path);
|
const input = String(conf.path);
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
path: [
|
path: [
|
||||||
'',
|
'',
|
||||||
'/',
|
'/',
|
||||||
@ -19,9 +19,9 @@ var bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = +conf.n;
|
const n = +conf.n;
|
||||||
var p = path.posix;
|
const p = path.posix;
|
||||||
var input = String(conf.path);
|
const input = String(conf.path);
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
path: [
|
path: [
|
||||||
'',
|
'',
|
||||||
'\\',
|
'\\',
|
||||||
@ -19,9 +19,9 @@ var bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = +conf.n;
|
const n = +conf.n;
|
||||||
var p = path.win32;
|
const p = path.win32;
|
||||||
var input = String(conf.path);
|
const input = String(conf.path);
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
var 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('|')
|
||||||
],
|
],
|
||||||
@ -10,10 +10,10 @@ var bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = +conf.n;
|
const n = +conf.n;
|
||||||
var p = path.posix;
|
const p = path.posix;
|
||||||
var props = String(conf.props).split('|');
|
const props = String(conf.props).split('|');
|
||||||
var obj = {
|
const obj = {
|
||||||
root: props[0] || '',
|
root: props[0] || '',
|
||||||
dir: props[1] || '',
|
dir: props[1] || '',
|
||||||
base: props[2] || '',
|
base: props[2] || '',
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
var 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('|')
|
||||||
],
|
],
|
||||||
@ -10,10 +10,10 @@ var bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = +conf.n;
|
const n = +conf.n;
|
||||||
var p = path.win32;
|
const p = path.win32;
|
||||||
var props = String(conf.props).split('|');
|
const props = String(conf.props).split('|');
|
||||||
var obj = {
|
const obj = {
|
||||||
root: props[0] || '',
|
root: props[0] || '',
|
||||||
dir: props[1] || '',
|
dir: props[1] || '',
|
||||||
base: props[2] || '',
|
base: props[2] || '',
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
path: [
|
path: [
|
||||||
'',
|
'',
|
||||||
'.',
|
'.',
|
||||||
@ -14,9 +14,9 @@ var bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = +conf.n;
|
const n = +conf.n;
|
||||||
var p = path.posix;
|
const p = path.posix;
|
||||||
var input = String(conf.path);
|
const input = String(conf.path);
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
path: [
|
path: [
|
||||||
'',
|
'',
|
||||||
'.',
|
'.',
|
||||||
@ -15,9 +15,9 @@ var bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = +conf.n;
|
const n = +conf.n;
|
||||||
var p = path.win32;
|
const p = path.win32;
|
||||||
var input = String(conf.path);
|
const input = String(conf.path);
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
paths: [
|
paths: [
|
||||||
['/foo', 'bar', '', 'baz/asdf', 'quux', '..'].join('|')
|
['/foo', 'bar', '', 'baz/asdf', 'quux', '..'].join('|')
|
||||||
],
|
],
|
||||||
@ -10,9 +10,9 @@ var bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = +conf.n;
|
const n = +conf.n;
|
||||||
var p = path.posix;
|
const p = path.posix;
|
||||||
var args = String(conf.paths).split('|');
|
const args = String(conf.paths).split('|');
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
var 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('|')
|
||||||
],
|
],
|
||||||
@ -10,9 +10,9 @@ var bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = +conf.n;
|
const n = +conf.n;
|
||||||
var p = path.win32;
|
const p = path.win32;
|
||||||
var args = String(conf.paths).split('|');
|
const args = String(conf.paths).split('|');
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
path: [
|
path: [
|
||||||
'foo\\bar',
|
'foo\\bar',
|
||||||
'C:\\foo',
|
'C:\\foo',
|
||||||
@ -13,9 +13,9 @@ var bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = +conf.n;
|
const n = +conf.n;
|
||||||
var p = path.win32;
|
const p = path.win32;
|
||||||
var input = String(conf.path);
|
const input = String(conf.path);
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
path: [
|
path: [
|
||||||
'',
|
'',
|
||||||
'.',
|
'.',
|
||||||
@ -15,9 +15,9 @@ var bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = +conf.n;
|
const n = +conf.n;
|
||||||
var p = path.posix;
|
const p = path.posix;
|
||||||
var input = String(conf.path);
|
const input = String(conf.path);
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
path: [
|
path: [
|
||||||
'',
|
'',
|
||||||
'.',
|
'.',
|
||||||
@ -15,9 +15,9 @@ var bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = +conf.n;
|
const n = +conf.n;
|
||||||
var p = path.win32;
|
const p = path.win32;
|
||||||
var input = String(conf.path);
|
const input = String(conf.path);
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
path: [
|
path: [
|
||||||
'',
|
'',
|
||||||
'/',
|
'/',
|
||||||
@ -16,9 +16,9 @@ var bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = +conf.n;
|
const n = +conf.n;
|
||||||
var p = path.posix;
|
const p = path.posix;
|
||||||
var input = String(conf.path);
|
const input = String(conf.path);
|
||||||
|
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
p.parse(input);
|
p.parse(input);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
path: [
|
path: [
|
||||||
'',
|
'',
|
||||||
'C:\\',
|
'C:\\',
|
||||||
@ -17,9 +17,9 @@ var bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = +conf.n;
|
const n = +conf.n;
|
||||||
var p = path.win32;
|
const p = path.win32;
|
||||||
var input = String(conf.path);
|
const input = String(conf.path);
|
||||||
|
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
p.parse(input);
|
p.parse(input);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
paths: [
|
paths: [
|
||||||
['/data/orandea/test/aaa', '/data/orandea/impl/bbb'].join('|'),
|
['/data/orandea/test/aaa', '/data/orandea/impl/bbb'].join('|'),
|
||||||
['/', '/var'].join('|'),
|
['/', '/var'].join('|'),
|
||||||
@ -16,11 +16,11 @@ var bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = +conf.n;
|
const n = +conf.n;
|
||||||
var p = path.posix;
|
const p = path.posix;
|
||||||
var from = String(conf.paths);
|
var from = String(conf.paths);
|
||||||
var to = '';
|
var to = '';
|
||||||
var delimIdx = from.indexOf('|');
|
const delimIdx = from.indexOf('|');
|
||||||
if (delimIdx > -1) {
|
if (delimIdx > -1) {
|
||||||
to = from.slice(delimIdx + 1);
|
to = from.slice(delimIdx + 1);
|
||||||
from = from.slice(0, delimIdx);
|
from = from.slice(0, delimIdx);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
paths: [
|
paths: [
|
||||||
['C:\\orandea\\test\\aaa', 'C:\\orandea\\impl\\bbb'].join('|'),
|
['C:\\orandea\\test\\aaa', 'C:\\orandea\\impl\\bbb'].join('|'),
|
||||||
['C:\\', 'D:\\'].join('|'),
|
['C:\\', 'D:\\'].join('|'),
|
||||||
@ -14,11 +14,11 @@ var bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = +conf.n;
|
const n = +conf.n;
|
||||||
var p = path.win32;
|
const p = path.win32;
|
||||||
var from = String(conf.paths);
|
var from = String(conf.paths);
|
||||||
var to = '';
|
var to = '';
|
||||||
var delimIdx = from.indexOf('|');
|
const delimIdx = from.indexOf('|');
|
||||||
if (delimIdx > -1) {
|
if (delimIdx > -1) {
|
||||||
to = from.slice(delimIdx + 1);
|
to = from.slice(delimIdx + 1);
|
||||||
from = from.slice(0, delimIdx);
|
from = from.slice(0, delimIdx);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
paths: [
|
paths: [
|
||||||
'',
|
'',
|
||||||
['', ''].join('|'),
|
['', ''].join('|'),
|
||||||
@ -13,9 +13,9 @@ var bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = +conf.n;
|
const n = +conf.n;
|
||||||
var p = path.posix;
|
const p = path.posix;
|
||||||
var args = String(conf.paths).split('|');
|
const args = String(conf.paths).split('|');
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
paths: [
|
paths: [
|
||||||
'',
|
'',
|
||||||
['', ''].join('|'),
|
['', ''].join('|'),
|
||||||
@ -13,9 +13,9 @@ var bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = +conf.n;
|
const n = +conf.n;
|
||||||
var p = path.win32;
|
const p = path.win32;
|
||||||
var args = String(conf.paths).split('|');
|
const args = String(conf.paths).split('|');
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
n: [1e5]
|
n: [1e5]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var n = +conf.n;
|
const n = +conf.n;
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
millions: [2]
|
millions: [2]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var N = +conf.millions * 1e6;
|
const N = +conf.millions * 1e6;
|
||||||
var n = 0;
|
var n = 0;
|
||||||
|
|
||||||
function cb1(arg1) {
|
function cb1(arg1) {
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
millions: [2]
|
millions: [2]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var N = +conf.millions * 1e6;
|
const N = +conf.millions * 1e6;
|
||||||
var n = 0;
|
var n = 0;
|
||||||
|
|
||||||
function cb() {
|
function cb() {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
millions: [12]
|
millions: [12]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
millions: [12]
|
millions: [12]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common.js');
|
const common = require('../common.js');
|
||||||
var querystring = require('querystring');
|
const querystring = require('querystring');
|
||||||
var inputs = require('../fixtures/url-inputs.js').searchParams;
|
const inputs = require('../fixtures/url-inputs.js').searchParams;
|
||||||
|
|
||||||
var bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
type: Object.keys(inputs),
|
type: Object.keys(inputs),
|
||||||
n: [1e6],
|
n: [1e6],
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
var type = conf.type;
|
const type = conf.type;
|
||||||
var n = conf.n | 0;
|
const n = conf.n | 0;
|
||||||
var input = inputs[type];
|
const input = inputs[type];
|
||||||
var i;
|
var i;
|
||||||
// Execute the function a "sufficient" number of times before the timed
|
// Execute the function a "sufficient" number of times before the timed
|
||||||
// loop to ensure the function is optimized just once.
|
// loop to ensure the function is optimized just once.
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user