Browse Source

benchmark: fix lint errors

PR-URL: https://github.com/nodejs/node/pull/5517
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
process-exit-stdio-flushing
Rich Trott 9 years ago
committed by James M Snell
parent
commit
1bedeeb41d
  1. 4
      benchmark/arrays/var-int.js
  2. 4
      benchmark/arrays/zero-float.js
  3. 4
      benchmark/arrays/zero-int.js
  4. 2
      benchmark/buffers/buffer-creation.js
  5. 5
      benchmark/buffers/buffer-indexof.js
  6. 25
      benchmark/compare.js
  7. 4
      benchmark/domain/domain-fn-args.js
  8. 3
      benchmark/fs/bench-readdir.js
  9. 3
      benchmark/fs/bench-readdirSync.js
  10. 4
      benchmark/http_simple_auto.js
  11. 7
      benchmark/http_simple_cluster.js
  12. 1
      benchmark/idle_clients.js
  13. 2
      benchmark/misc/freelist.js
  14. 2
      benchmark/misc/v8-bench.js
  15. 10
      benchmark/module/module-loader.js
  16. 6
      benchmark/tls/throughput.js

4
benchmark/arrays/var-int.js

@ -1,7 +1,9 @@
'use strict'; 'use strict';
var common = require('../common.js'); var common = require('../common.js');
var bench = common.createBenchmark(main, { var bench = common.createBenchmark(main, {
type: 'Array Buffer Int8Array Uint8Array Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array'.split(' '), type: ['Array', 'Buffer', 'Int8Array', 'Uint8Array', 'Int16Array',
'Uint16Array', 'Int32Array', 'Uint32Array', 'Float32Array',
'Float64Array'],
n: [25] n: [25]
}); });

4
benchmark/arrays/zero-float.js

@ -1,7 +1,9 @@
'use strict'; 'use strict';
var common = require('../common.js'); var common = require('../common.js');
var bench = common.createBenchmark(main, { var bench = common.createBenchmark(main, {
type: 'Array Buffer Int8Array Uint8Array Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array'.split(' '), type: ['Array', 'Buffer', 'Int8Array', 'Uint8Array', 'Int16Array',
'Uint16Array', 'Int32Array', 'Uint32Array', 'Float32Array',
'Float64Array'],
n: [25] n: [25]
}); });

4
benchmark/arrays/zero-int.js

@ -1,7 +1,9 @@
'use strict'; 'use strict';
var common = require('../common.js'); var common = require('../common.js');
var bench = common.createBenchmark(main, { var bench = common.createBenchmark(main, {
type: 'Array Buffer Int8Array Uint8Array Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array'.split(' '), type: ['Array', 'Buffer', 'Int8Array', 'Uint8Array', 'Int16Array',
'Uint16Array', 'Int32Array', 'Uint32Array', 'Float32Array',
'Float64Array'],
n: [25] n: [25]
}); });

2
benchmark/buffers/buffer-creation.js

@ -14,7 +14,7 @@ function main(conf) {
var clazz = conf.type === 'fast' ? Buffer : SlowBuffer; var clazz = conf.type === 'fast' ? Buffer : SlowBuffer;
bench.start(); bench.start();
for (var i = 0; i < n * 1024; i++) { for (var i = 0; i < n * 1024; i++) {
b = new clazz(len); new clazz(len);
} }
bench.end(n); bench.end(n);
} }

5
benchmark/buffers/buffer-indexof.js

@ -1,6 +1,7 @@
'use strict'; 'use strict';
var common = require('../common.js'); var common = require('../common.js');
var fs = require('fs'); var fs = require('fs');
const path = require('path');
var bench = common.createBenchmark(main, { var bench = common.createBenchmark(main, {
search: ['@', 'SQ', '10x', '--l', 'Alice', 'Gryphon', 'Panther', search: ['@', 'SQ', '10x', '--l', 'Alice', 'Gryphon', 'Panther',
@ -15,7 +16,9 @@ var bench = common.createBenchmark(main, {
function main(conf) { function main(conf) {
var iter = (conf.iter) * 100000; var iter = (conf.iter) * 100000;
var aliceBuffer = fs.readFileSync(__dirname + '/../fixtures/alice.html'); var aliceBuffer = fs.readFileSync(
path.resolve(__dirname, '../fixtures/alice.html')
);
var search = conf.search; var search = conf.search;
var encoding = conf.encoding; var encoding = conf.encoding;

25
benchmark/compare.js

@ -77,10 +77,15 @@ function run() {
var out = ''; var out = '';
var child; var child;
if (Array.isArray(benchmarks) && benchmarks.length) if (Array.isArray(benchmarks) && benchmarks.length) {
child = spawn(node, ['benchmark/common.js'].concat(benchmarks), { env: env }); child = spawn(
else node,
['benchmark/common.js'].concat(benchmarks),
{ env: env }
);
} else {
child = spawn('make', [runBench], { env: env }); child = spawn('make', [runBench], { env: env });
}
child.stdout.setEncoding('utf8'); child.stdout.setEncoding('utf8');
child.stdout.on('data', function(c) { child.stdout.on('data', function(c) {
out += c; out += c;
@ -136,8 +141,18 @@ function compare() {
if (show === 'green' && !g || show === 'red' && !r) if (show === 'green' && !g || show === 'red' && !r)
return; return;
var r0 = util.format('%s%s: %d%s', g, nodes[0], n0.toPrecision(5), g ? reset : ''); var r0 = util.format(
var r1 = util.format('%s%s: %d%s', r, nodes[1], n1.toPrecision(5), r ? reset : ''); '%s%s: %d%s',
g,
nodes[0],
n0.toPrecision(5), g ? reset : ''
);
var r1 = util.format(
'%s%s: %d%s',
r,
nodes[1],
n1.toPrecision(5), r ? reset : ''
);
pct = c + pct + '%' + reset; pct = c + pct + '%' + reset;
var l = util.format('%s: %s %s', bench, r0, r1); var l = util.format('%s: %s %s', bench, r0, r1);
maxLen = Math.max(l.length + pct.length, maxLen); maxLen = Math.max(l.length + pct.length, maxLen);

4
benchmark/domain/domain-fn-args.js

@ -20,9 +20,9 @@ function main(conf) {
for (var i = 0; i < n; i++) { for (var i = 0; i < n; i++) {
if (myArguments.length >= 2) { if (myArguments.length >= 2) {
args = Array.prototype.slice.call(myArguments, 1); args = Array.prototype.slice.call(myArguments, 1);
ret = fn.apply(this, args); fn.apply(this, args);
} else { } else {
ret = fn.call(this); fn.call(this);
} }
} }
bdomain.exit(); bdomain.exit();

3
benchmark/fs/bench-readdir.js

@ -2,6 +2,7 @@
const common = require('../common'); const common = require('../common');
const fs = require('fs'); const fs = require('fs');
const path = require('path');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
n: [1e4], n: [1e4],
@ -15,7 +16,7 @@ function main(conf) {
(function r(cntr) { (function r(cntr) {
if (--cntr <= 0) if (--cntr <= 0)
return bench.end(n); return bench.end(n);
fs.readdir(__dirname + '/../../lib/', function() { fs.readdir(path.resolve(__dirname, '../../lib/'), function() {
r(cntr); r(cntr);
}); });
}(n)); }(n));

3
benchmark/fs/bench-readdirSync.js

@ -2,6 +2,7 @@
const common = require('../common'); const common = require('../common');
const fs = require('fs'); const fs = require('fs');
const path = require('path');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
n: [1e4], n: [1e4],
@ -13,7 +14,7 @@ function main(conf) {
bench.start(); bench.start();
for (var i = 0; i < n; i++) { for (var i = 0; i < n; i++) {
fs.readdirSync(__dirname + '/../../lib/'); fs.readdirSync(path.resolve(__dirname, '../../lib/'));
} }
bench.end(n); bench.end(n);
} }

4
benchmark/http_simple_auto.js

@ -111,10 +111,10 @@ server.listen(port, function() {
}); });
function dump_mm_stats() { function dump_mm_stats() {
if (typeof gc != 'function') return; if (typeof global.gc != 'function') return;
var before = process.memoryUsage(); var before = process.memoryUsage();
for (var i = 0; i < 10; ++i) gc(); for (var i = 0; i < 10; ++i) global.gc();
var after = process.memoryUsage(); var after = process.memoryUsage();
setTimeout(print_stats, 250); // give GC time to settle setTimeout(print_stats, 250); // give GC time to settle

7
benchmark/http_simple_cluster.js

@ -1,10 +1,11 @@
'use strict'; 'use strict';
var cluster = require('cluster'); const cluster = require('cluster');
var os = require('os'); const os = require('os');
const path = require('path');
if (cluster.isMaster) { if (cluster.isMaster) {
console.log('master running on pid %d', process.pid); console.log('master running on pid %d', process.pid);
for (var i = 0, n = os.cpus().length; i < n; ++i) cluster.fork(); for (var i = 0, n = os.cpus().length; i < n; ++i) cluster.fork();
} else { } else {
require(__dirname + '/http_simple.js'); require(path.join(__dirname, 'http_simple.js'));
} }

1
benchmark/idle_clients.js

@ -17,7 +17,6 @@ function connect() {
s.on('close', function() { s.on('close', function() {
if (gotConnected) connections--; if (gotConnected) connections--;
lastClose = new Date();
}); });
s.on('error', function() { s.on('error', function() {

2
benchmark/misc/freelist.js

@ -22,7 +22,7 @@ function main(conf) {
bench.start(); bench.start();
for (i = 0; i < n; i++){ for (i = 0; i < n; i++) {
// Return all the items to the pool // Return all the items to the pool
for (j = 0; j < poolSize; j++) { for (j = 0; j < poolSize; j++) {
list.free(used[j]); list.free(used[j]);

2
benchmark/misc/v8-bench.js

@ -20,4 +20,4 @@ global.load = function(filename) {
global.RegExp = $RegExp; global.RegExp = $RegExp;
}; };
load('run.js'); global.load('run.js');

10
benchmark/module/module-loader.js

@ -18,8 +18,14 @@ function main(conf) {
var n = +conf.thousands * 1e3; var n = +conf.thousands * 1e3;
for (var i = 0; i <= n; i++) { for (var i = 0; i <= n; i++) {
fs.mkdirSync(benchmarkDirectory + i); fs.mkdirSync(benchmarkDirectory + i);
fs.writeFileSync(benchmarkDirectory + i + '/package.json', '{"main": "index.js"}'); fs.writeFileSync(
fs.writeFileSync(benchmarkDirectory + i + '/index.js', 'module.exports = "";'); benchmarkDirectory + i + '/package.json',
'{"main": "index.js"}'
);
fs.writeFileSync(
benchmarkDirectory + i + '/index.js',
'module.exports = "";'
);
} }
measure(n); measure(n);

6
benchmark/tls/throughput.js

@ -45,9 +45,10 @@ function main(conf) {
server = tls.createServer(options, onConnection); server = tls.createServer(options, onConnection);
setTimeout(done, dur * 1000); setTimeout(done, dur * 1000);
var conn;
server.listen(common.PORT, function() { server.listen(common.PORT, function() {
var opt = { port: common.PORT, rejectUnauthorized: false }; var opt = { port: common.PORT, rejectUnauthorized: false };
var conn = tls.connect(opt, function() { conn = tls.connect(opt, function() {
bench.start(); bench.start();
conn.on('drain', write); conn.on('drain', write);
write(); write();
@ -68,7 +69,8 @@ function main(conf) {
function done() { function done() {
var mbits = (received * 8) / (1024 * 1024); var mbits = (received * 8) / (1024 * 1024);
bench.end(mbits); bench.end(mbits);
conn.destroy(); if (conn)
conn.destroy();
server.close(); server.close();
} }
} }

Loading…
Cancel
Save