diff --git a/benchmark/arrays/var-int.js b/benchmark/arrays/var-int.js index 47a7e62dc7681b..2b5fefc126ac1f 100644 --- a/benchmark/arrays/var-int.js +++ b/benchmark/arrays/var-int.js @@ -1,6 +1,8 @@ var common = require('../common.js'); 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] }); diff --git a/benchmark/arrays/zero-float.js b/benchmark/arrays/zero-float.js index a6624205bffdea..015e9a08f95725 100644 --- a/benchmark/arrays/zero-float.js +++ b/benchmark/arrays/zero-float.js @@ -1,6 +1,8 @@ var common = require('../common.js'); 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] }); diff --git a/benchmark/arrays/zero-int.js b/benchmark/arrays/zero-int.js index 29a2d58b665cbe..4dad3e9980e78b 100644 --- a/benchmark/arrays/zero-int.js +++ b/benchmark/arrays/zero-int.js @@ -1,6 +1,8 @@ var common = require('../common.js'); 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] }); diff --git a/benchmark/buffers/buffer-creation.js b/benchmark/buffers/buffer-creation.js index bc0c55711858de..fc498d0bf717d7 100644 --- a/benchmark/buffers/buffer-creation.js +++ b/benchmark/buffers/buffer-creation.js @@ -13,7 +13,7 @@ function main(conf) { var clazz = conf.type === 'fast' ? Buffer : SlowBuffer; bench.start(); for (var i = 0; i < n * 1024; i++) { - b = new clazz(len); + new clazz(len); } bench.end(n); } diff --git a/benchmark/buffers/buffer-indexof.js b/benchmark/buffers/buffer-indexof.js index c575f54b6a638c..0f54930296f268 100644 --- a/benchmark/buffers/buffer-indexof.js +++ b/benchmark/buffers/buffer-indexof.js @@ -1,5 +1,6 @@ var common = require('../common.js'); var fs = require('fs'); +const path = require('path'); var bench = common.createBenchmark(main, { search: ['@', 'SQ', '10x', '--l', 'Alice', 'Gryphon', 'Panther', @@ -14,7 +15,9 @@ var bench = common.createBenchmark(main, { function main(conf) { 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 encoding = conf.encoding; diff --git a/benchmark/compare.js b/benchmark/compare.js index edb116d0c64baa..94d8cb515fbb03 100644 --- a/benchmark/compare.js +++ b/benchmark/compare.js @@ -75,10 +75,15 @@ function run() { var out = ''; var child; - if (Array.isArray(benchmarks) && benchmarks.length) - child = spawn(node, ['benchmark/common.js'].concat(benchmarks), { env: env }); - else + if (Array.isArray(benchmarks) && benchmarks.length) { + child = spawn( + node, + ['benchmark/common.js'].concat(benchmarks), + { env: env } + ); + } else { child = spawn('make', [runBench], { env: env }); + } child.stdout.setEncoding('utf8'); child.stdout.on('data', function(c) { out += c; @@ -134,9 +139,20 @@ function compare() { if (show === 'green' && !g || show === 'red' && !r) return; - var r0 = util.format('%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 : ''); - var pct = c + pct + '%' + reset; + var r0 = util.format( + '%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; + var l = util.format('%s: %s %s', bench, r0, r1); maxLen = Math.max(l.length + pct.length, maxLen); return [l, pct]; diff --git a/benchmark/http_simple_auto.js b/benchmark/http_simple_auto.js index f72cc01e60aa46..0769f834081c7c 100644 --- a/benchmark/http_simple_auto.js +++ b/benchmark/http_simple_auto.js @@ -109,10 +109,10 @@ server.listen(port, function () { }); function dump_mm_stats() { - if (typeof gc != 'function') return; + if (typeof global.gc != 'function') return; 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(); setTimeout(print_stats, 250); // give GC time to settle diff --git a/benchmark/http_simple_cluster.js b/benchmark/http_simple_cluster.js index 9a886f2ee75dab..f48a2a2599a78f 100644 --- a/benchmark/http_simple_cluster.js +++ b/benchmark/http_simple_cluster.js @@ -1,9 +1,11 @@ -var cluster = require('cluster'); -var os = require('os'); +'use strict'; +const cluster = require('cluster'); +const os = require('os'); +const path = require('path'); if (cluster.isMaster) { console.log('master running on pid %d', process.pid); for (var i = 0, n = os.cpus().length; i < n; ++i) cluster.fork(); } else { - require(__dirname + '/http_simple.js'); + require(path.join(__dirname, 'http_simple.js')); } diff --git a/benchmark/idle_clients.js b/benchmark/idle_clients.js index da96b8ac654db4..f061ff4d859836 100644 --- a/benchmark/idle_clients.js +++ b/benchmark/idle_clients.js @@ -18,7 +18,6 @@ function connect () { s.on('close', function () { if (gotConnected) connections--; - lastClose = new Date(); }); s.on('error', function () { diff --git a/benchmark/misc/domain-fn-args.js b/benchmark/misc/domain-fn-args.js index 36e9e900299bb2..9cc17fa8fd94f5 100644 --- a/benchmark/misc/domain-fn-args.js +++ b/benchmark/misc/domain-fn-args.js @@ -21,7 +21,7 @@ function main(conf) { args = Array.prototype.slice.call(arguments, 1); ret = fn.apply(this, args); } else { - ret = fn.call(this); + fn.call(this); } } bdomain.exit(); diff --git a/benchmark/misc/freelist.js b/benchmark/misc/freelist.js index 76275000b08ffb..7956dc3d6b18c0 100644 --- a/benchmark/misc/freelist.js +++ b/benchmark/misc/freelist.js @@ -22,7 +22,7 @@ function main(conf) { bench.start(); - for (i = 0; i < n; i++){ + for (i = 0; i < n; i++) { // Return all the items to the pool for (j = 0; j < poolSize; j++) { list.free(used[j]); diff --git a/benchmark/misc/module-loader.js b/benchmark/misc/module-loader.js index e53bc4d801164b..fcda0a288b9e54 100644 --- a/benchmark/misc/module-loader.js +++ b/benchmark/misc/module-loader.js @@ -18,8 +18,14 @@ function main(conf) { var n = +conf.thousands * 1e3; for (var i = 0; i <= n; i++) { fs.mkdirSync(benchmarkDirectory + i); - fs.writeFileSync(benchmarkDirectory + i + '/package.json', '{"main": "index.js"}'); - fs.writeFileSync(benchmarkDirectory + i + '/index.js', 'module.exports = "";'); + fs.writeFileSync( + benchmarkDirectory + i + '/package.json', + '{"main": "index.js"}' + ); + fs.writeFileSync( + benchmarkDirectory + i + '/index.js', + 'module.exports = "";' + ); } measure(n); diff --git a/benchmark/misc/v8-bench.js b/benchmark/misc/v8-bench.js index 0eb95aa9e2b2bc..efe81f8ebb8a0e 100644 --- a/benchmark/misc/v8-bench.js +++ b/benchmark/misc/v8-bench.js @@ -19,4 +19,4 @@ global.load = function(filename) { global.RegExp = $RegExp; }; -load('run.js'); +global.load('run.js'); diff --git a/benchmark/tls/throughput.js b/benchmark/tls/throughput.js index 442eba338ed643..e4873e651fcb25 100644 --- a/benchmark/tls/throughput.js +++ b/benchmark/tls/throughput.js @@ -44,9 +44,10 @@ function main(conf) { server = tls.createServer(options, onConnection); setTimeout(done, dur * 1000); + var conn; server.listen(common.PORT, function() { var opt = { port: common.PORT, rejectUnauthorized: false }; - var conn = tls.connect(opt, function() { + conn = tls.connect(opt, function() { bench.start(); conn.on('drain', write); write(); @@ -68,7 +69,8 @@ function main(conf) { function done() { var mbits = (received * 8) / (1024 * 1024); bench.end(mbits); - conn.destroy(); + if (conn) + conn.destroy(); server.close(); } }