diff options
-rw-r--r-- | benchmark/async_hooks/gc-tracking.js | 7 | ||||
-rw-r--r-- | benchmark/dgram/bind-params.js | 7 | ||||
-rw-r--r-- | benchmark/domain/domain-fn-args.js | 11 | ||||
-rw-r--r-- | benchmark/fs/bench-realpath.js | 4 | ||||
-rw-r--r-- | benchmark/fs/bench-realpathSync.js | 20 | ||||
-rw-r--r-- | benchmark/fs/write-stream-throughput.js | 7 | ||||
-rw-r--r-- | benchmark/misc/freelist.js | 3 | ||||
-rw-r--r-- | benchmark/misc/function_call/index.js | 4 | ||||
-rw-r--r-- | benchmark/misc/object-property-bench.js | 2 | ||||
-rw-r--r-- | benchmark/misc/punycode.js | 5 | ||||
-rw-r--r-- | benchmark/module/module-loader.js | 24 | ||||
-rw-r--r-- | benchmark/tls/convertprotocols.js | 7 | ||||
-rw-r--r-- | benchmark/util/format.js | 4 | ||||
-rw-r--r-- | benchmark/util/inspect-array.js | 5 | ||||
-rw-r--r-- | benchmark/v8/get-stats.js | 3 | ||||
-rw-r--r-- | benchmark/vm/run-in-context.js | 4 | ||||
-rw-r--r-- | benchmark/vm/run-in-this-context.js | 4 |
17 files changed, 39 insertions, 82 deletions
diff --git a/benchmark/async_hooks/gc-tracking.js b/benchmark/async_hooks/gc-tracking.js index a569fb8fa92..d74b2bac463 100644 --- a/benchmark/async_hooks/gc-tracking.js +++ b/benchmark/async_hooks/gc-tracking.js @@ -22,22 +22,23 @@ function endAfterGC(n) { } function main({ n, method }) { + var i; switch (method) { case 'trackingEnabled': bench.start(); - for (let i = 0; i < n; i++) { + for (i = 0; i < n; i++) { new AsyncResource('foobar'); } endAfterGC(n); break; case 'trackingDisabled': bench.start(); - for (let i = 0; i < n; i++) { + for (i = 0; i < n; i++) { new AsyncResource('foobar', { requireManualDestroy: true }); } endAfterGC(n); break; default: - throw new Error('Unsupported method'); + throw new Error(`Unsupported method "${method}"`); } } diff --git a/benchmark/dgram/bind-params.js b/benchmark/dgram/bind-params.js index 5f7999f7a39..ea1f430eed9 100644 --- a/benchmark/dgram/bind-params.js +++ b/benchmark/dgram/bind-params.js @@ -15,10 +15,11 @@ const noop = () => {}; function main({ n, port, address }) { port = port === 'true' ? 0 : undefined; address = address === 'true' ? '0.0.0.0' : undefined; + var i; if (port !== undefined && address !== undefined) { bench.start(); - for (let i = 0; i < n; i++) { + for (i = 0; i < n; i++) { dgram.createSocket('udp4').bind(port, address) .on('error', noop) .unref(); @@ -26,7 +27,7 @@ function main({ n, port, address }) { bench.end(n); } else if (port !== undefined) { bench.start(); - for (let i = 0; i < n; i++) { + for (i = 0; i < n; i++) { dgram.createSocket('udp4') .bind(port) .on('error', noop) @@ -35,7 +36,7 @@ function main({ n, port, address }) { bench.end(n); } else if (port === undefined && address === undefined) { bench.start(); - for (let i = 0; i < n; i++) { + for (i = 0; i < n; i++) { dgram.createSocket('udp4') .bind() .on('error', noop) diff --git a/benchmark/domain/domain-fn-args.js b/benchmark/domain/domain-fn-args.js index fe912e34d20..c889b35442d 100644 --- a/benchmark/domain/domain-fn-args.js +++ b/benchmark/domain/domain-fn-args.js @@ -28,15 +28,6 @@ function main({ n, args }) { bench.end(n); } -function fn(a, b, c) { - if (!a) - a = 1; - - if (!b) - b = 2; - - if (!c) - c = 3; - +function fn(a = 1, b = 2, c = 3) { return a + b + c; } diff --git a/benchmark/fs/bench-realpath.js b/benchmark/fs/bench-realpath.js index 6690d7e87b0..de03e71b42d 100644 --- a/benchmark/fs/bench-realpath.js +++ b/benchmark/fs/bench-realpath.js @@ -16,10 +16,8 @@ function main({ n, pathType }) { bench.start(); if (pathType === 'relative') relativePath(n); - else if (pathType === 'resolved') - resolvedPath(n); else - throw new Error(`unknown "pathType": ${pathType}`); + resolvedPath(n); } function relativePath(n) { diff --git a/benchmark/fs/bench-realpathSync.js b/benchmark/fs/bench-realpathSync.js index 1c751156f73..7a01bd18cb7 100644 --- a/benchmark/fs/bench-realpathSync.js +++ b/benchmark/fs/bench-realpathSync.js @@ -15,24 +15,10 @@ const bench = common.createBenchmark(main, { function main({ n, pathType }) { + const path = pathType === 'relative' ? relative_path : resolved_path; bench.start(); - if (pathType === 'relative') - relativePath(n); - else if (pathType === 'resolved') - resolvedPath(n); - else - throw new Error(`unknown "pathType": ${pathType}`); - bench.end(n); -} - -function relativePath(n) { - for (var i = 0; i < n; i++) { - fs.realpathSync(relative_path); - } -} - -function resolvedPath(n) { for (var i = 0; i < n; i++) { - fs.realpathSync(resolved_path); + fs.realpathSync(path); } + bench.end(n); } diff --git a/benchmark/fs/write-stream-throughput.js b/benchmark/fs/write-stream-throughput.js index 6fe00cde48c..60ad47bc4ea 100644 --- a/benchmark/fs/write-stream-throughput.js +++ b/benchmark/fs/write-stream-throughput.js @@ -36,7 +36,6 @@ function main({ dur, encodingType, size }) { try { fs.unlinkSync(filename); } catch (e) {} var started = false; - var ending = false; var ended = false; var f = fs.createWriteStream(filename); @@ -52,15 +51,9 @@ function main({ dur, encodingType, size }) { function write() { - // don't try to write after we end, even if a 'drain' event comes. - // v0.8 streams are so sloppy! - if (ending) - return; - if (!started) { started = true; setTimeout(function() { - ending = true; f.end(); }, dur * 1000); bench.start(); diff --git a/benchmark/misc/freelist.js b/benchmark/misc/freelist.js index 0530255728f..8c3281cc407 100644 --- a/benchmark/misc/freelist.js +++ b/benchmark/misc/freelist.js @@ -12,7 +12,6 @@ function main({ n }) { const FreeList = require('internal/freelist'); const poolSize = 1000; const list = new FreeList('test', poolSize, Object); - var i; var j; const used = []; @@ -23,7 +22,7 @@ function main({ n }) { bench.start(); - for (i = 0; i < n; i++) { + for (var 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/function_call/index.js b/benchmark/misc/function_call/index.js index 91efa573597..28561bc48cd 100644 --- a/benchmark/misc/function_call/index.js +++ b/benchmark/misc/function_call/index.js @@ -32,11 +32,9 @@ const bench = common.createBenchmark(main, { }); function main({ millions, type }) { - const n = millions * 1e6; - const fn = type === 'cxx' ? cxx : js; bench.start(); - for (var i = 0; i < n; i++) { + for (var i = 0; i < millions * 1e6; i++) { fn(); } bench.end(millions); diff --git a/benchmark/misc/object-property-bench.js b/benchmark/misc/object-property-bench.js index 37da82d8875..ddc6faed7fc 100644 --- a/benchmark/misc/object-property-bench.js +++ b/benchmark/misc/object-property-bench.js @@ -78,6 +78,6 @@ function main({ millions, method }) { runSymbol(n); break; default: - throw new Error('Unexpected method'); + throw new Error(`Unexpected method "${method}"`); } } diff --git a/benchmark/misc/punycode.js b/benchmark/misc/punycode.js index 7016fa11712..369adcf17d3 100644 --- a/benchmark/misc/punycode.js +++ b/benchmark/misc/punycode.js @@ -55,9 +55,8 @@ function runPunycode(n, val) { } function runICU(n, val) { - var i = 0; bench.start(); - for (; i < n; i++) + for (var i = 0; i < n; i++) usingICU(val); bench.end(n); } @@ -76,6 +75,6 @@ function main({ n, val, method }) { } // fallthrough default: - throw new Error('Unexpected method'); + throw new Error(`Unexpected method "${method}"`); } } diff --git a/benchmark/module/module-loader.js b/benchmark/module/module-loader.js index 25f0ece7016..58d4dcf81c9 100644 --- a/benchmark/module/module-loader.js +++ b/benchmark/module/module-loader.js @@ -13,12 +13,10 @@ const bench = common.createBenchmark(main, { }); function main({ thousands, fullPath, useCache }) { - const n = thousands * 1e3; - tmpdir.refresh(); try { fs.mkdirSync(benchmarkDirectory); } catch (e) {} - for (var i = 0; i <= n; i++) { + for (var i = 0; i <= thousands * 1e3; i++) { fs.mkdirSync(`${benchmarkDirectory}${i}`); fs.writeFileSync( `${benchmarkDirectory}${i}/package.json`, @@ -31,37 +29,37 @@ function main({ thousands, fullPath, useCache }) { } if (fullPath === 'true') - measureFull(n, useCache === 'true'); + measureFull(thousands, useCache === 'true'); else - measureDir(n, useCache === 'true'); + measureDir(thousands, useCache === 'true'); tmpdir.refresh(); } -function measureFull(n, useCache) { +function measureFull(thousands, useCache) { var i; if (useCache) { - for (i = 0; i <= n; i++) { + for (i = 0; i <= thousands * 1e3; i++) { require(`${benchmarkDirectory}${i}/index.js`); } } bench.start(); - for (i = 0; i <= n; i++) { + for (i = 0; i <= thousands * 1e3; i++) { require(`${benchmarkDirectory}${i}/index.js`); } - bench.end(n / 1e3); + bench.end(thousands); } -function measureDir(n, useCache) { +function measureDir(thousands, useCache) { var i; if (useCache) { - for (i = 0; i <= n; i++) { + for (i = 0; i <= thousands * 1e3; i++) { require(`${benchmarkDirectory}${i}`); } } bench.start(); - for (i = 0; i <= n; i++) { + for (i = 0; i <= thousands * 1e3; i++) { require(`${benchmarkDirectory}${i}`); } - bench.end(n / 1e3); + bench.end(thousands); } diff --git a/benchmark/tls/convertprotocols.js b/benchmark/tls/convertprotocols.js index 1ee2672bee7..9f4969344d1 100644 --- a/benchmark/tls/convertprotocols.js +++ b/benchmark/tls/convertprotocols.js @@ -8,14 +8,15 @@ const bench = common.createBenchmark(main, { }); function main({ n }) { - var i = 0; + const input = ['ABC', 'XYZ123', 'FOO']; var m = {}; // First call dominates results if (n > 1) { - tls.convertNPNProtocols(['ABC', 'XYZ123', 'FOO'], m); + tls.convertNPNProtocols(input, m); m = {}; } bench.start(); - for (; i < n; i++) tls.convertNPNProtocols(['ABC', 'XYZ123', 'FOO'], m); + for (var i = 0; i < n; i++) + tls.convertNPNProtocols(input, m); bench.end(n); } diff --git a/benchmark/util/format.js b/benchmark/util/format.js index 5f9c4c3b594..042b8a93ccf 100644 --- a/benchmark/util/format.js +++ b/benchmark/util/format.js @@ -22,9 +22,7 @@ const bench = common.createBenchmark(main, { function main({ n, type }) { // For testing, if supplied with an empty type, default to string. - type = type || 'string'; - - const [first, second] = inputs[type]; + const [first, second] = inputs[type || 'string']; bench.start(); for (var i = 0; i < n; i++) { diff --git a/benchmark/util/inspect-array.js b/benchmark/util/inspect-array.js index 74332d18579..8b3c54aeb94 100644 --- a/benchmark/util/inspect-array.js +++ b/benchmark/util/inspect-array.js @@ -18,14 +18,13 @@ function main({ n, len, type }) { var arr = Array(len); var i, opts; - // For testing, if supplied with an empty type, default to denseArray. - type = type || 'denseArray'; - switch (type) { case 'denseArray_showHidden': opts = { showHidden: true }; arr = arr.fill('denseArray'); break; + // For testing, if supplied with an empty type, default to denseArray. + case '': case 'denseArray': arr = arr.fill('denseArray'); break; diff --git a/benchmark/v8/get-stats.js b/benchmark/v8/get-stats.js index 6ee74285862..84a0655f5db 100644 --- a/benchmark/v8/get-stats.js +++ b/benchmark/v8/get-stats.js @@ -12,9 +12,8 @@ const bench = common.createBenchmark(main, { }); function main({ method, n }) { - var i = 0; bench.start(); - for (; i < n; i++) + for (var i = 0; i < n; i++) v8[method](); bench.end(n); } diff --git a/benchmark/vm/run-in-context.js b/benchmark/vm/run-in-context.js index da8f56a6e01..9b57067a19c 100644 --- a/benchmark/vm/run-in-context.js +++ b/benchmark/vm/run-in-context.js @@ -17,12 +17,10 @@ function main({ n, breakOnSigint, withSigintListener }) { if (withSigintListener) process.on('SIGINT', () => {}); - var i = 0; - const contextifiedSandbox = vm.createContext(); bench.start(); - for (; i < n; i++) + for (var i = 0; i < n; i++) vm.runInContext('0', contextifiedSandbox, options); bench.end(n); } diff --git a/benchmark/vm/run-in-this-context.js b/benchmark/vm/run-in-this-context.js index 33fd3a34d81..0754287376d 100644 --- a/benchmark/vm/run-in-this-context.js +++ b/benchmark/vm/run-in-this-context.js @@ -17,10 +17,8 @@ function main({ n, breakOnSigint, withSigintListener }) { if (withSigintListener) process.on('SIGINT', () => {}); - var i = 0; - bench.start(); - for (; i < n; i++) + for (var i = 0; i < n; i++) vm.runInThisContext('0', options); bench.end(n); } |