diff --git a/benchmark/_benchmark_progress.js b/benchmark/_benchmark_progress.js index 4afae2f77d4d2f..5e2ae4ab11dc75 100644 --- a/benchmark/_benchmark_progress.js +++ b/benchmark/_benchmark_progress.js @@ -3,12 +3,13 @@ const readline = require('readline'); function pad(input, minLength, fill) { - var result = input + ''; - return fill.repeat(Math.max(0, minLength - result.length)) + result; + var result = String(input); + var padding = fill.repeat(Math.max(0, minLength - result.length)); + return `${padding}${result}`; } function fraction(numerator, denominator) { - const fdenominator = denominator + ''; + const fdenominator = String(denominator); const fnumerator = pad(numerator, fdenominator.length, ' '); return `${fnumerator}/${fdenominator}`; } @@ -100,11 +101,12 @@ class BenchmarkProgress { const percent = pad(Math.floor(completedRate * 100), 3, ' '); const caption = finished ? 'Done\n' : this.currentFile; - return `[${getTime(diff)}|% ${percent}` + - `| ${fraction(completedFiles, scheduledFiles)} files ` + - `| ${fraction(completedRunsForFile, runsPerFile)} runs ` + - `| ${fraction(completedConfig, scheduledConfig)} configs]` + - `: ${caption} `; + return `[${getTime(diff)}|% ${ + percent}| ${ + fraction(completedFiles, scheduledFiles)} files | ${ + fraction(completedRunsForFile, runsPerFile)} runs | ${ + fraction(completedConfig, scheduledConfig)} configs]: ${ + caption} `; } updateProgress(finished) { diff --git a/benchmark/_http-benchmarkers.js b/benchmark/_http-benchmarkers.js index 78e4248bfab46e..4ad4ab9994ba99 100644 --- a/benchmark/_http-benchmarkers.js +++ b/benchmark/_http-benchmarkers.js @@ -4,6 +4,9 @@ const child_process = require('child_process'); const path = require('path'); const fs = require('fs'); +const requirementsURL = + 'https://github.com/nodejs/node/blob/master/doc/guides/writing-and-running-benchmarks.md##http-benchmark-requirements'; + // The port used by servers and wrk exports.PORT = process.env.PORT || 12346; @@ -133,20 +136,19 @@ exports.run = function(options, callback) { benchmarker: exports.default_http_benchmarker }, options); if (!options.benchmarker) { - callback(new Error('Could not locate required http benchmarker. See ' + - 'https://github.com/nodejs/node/blob/master/doc/guides/writing-and-running-benchmarks.md##http-benchmark-requirements ' + - 'for further instructions.')); + callback(new Error(`Could not locate required http benchmarker. See ${ + requirementsURL} for further instructions.`)); return; } const benchmarker = benchmarkers[options.benchmarker]; if (!benchmarker) { - callback(new Error(`Requested benchmarker '${options.benchmarker}' is ` + - 'not supported')); + callback(new Error(`Requested benchmarker '${ + options.benchmarker}' is not supported`)); return; } if (!benchmarker.present) { - callback(new Error(`Requested benchmarker '${options.benchmarker}' is ` + - 'not installed')); + callback(new Error(`Requested benchmarker '${ + options.benchmarker}' is not installed`)); return; } @@ -172,8 +174,8 @@ exports.run = function(options, callback) { const result = benchmarker.processResults(stdout); if (result === undefined) { - callback(new Error(`${options.benchmarker} produced strange output: ` + - stdout, code)); + callback(new Error( + `${options.benchmarker} produced strange output: ${stdout}`, code)); return; } diff --git a/benchmark/assert/deepequal-typedarrays.js b/benchmark/assert/deepequal-typedarrays.js index 037cfb2cf1ec3c..00c6ca5adf2835 100644 --- a/benchmark/assert/deepequal-typedarrays.js +++ b/benchmark/assert/deepequal-typedarrays.js @@ -2,8 +2,17 @@ const common = require('../common.js'); const assert = require('assert'); const bench = common.createBenchmark(main, { - type: ('Int8Array Uint8Array Int16Array Uint16Array Int32Array Uint32Array ' + - 'Float32Array Float64Array Uint8ClampedArray').split(' '), + type: [ + 'Int8Array', + 'Uint8Array', + 'Int16Array', + 'Uint16Array', + 'Int32Array', + 'Uint32Array', + 'Float32Array', + 'Float64Array', + 'Uint8ClampedArray', + ], n: [1], method: ['strict', 'nonstrict'], len: [1e6] diff --git a/benchmark/buffers/buffer-base64-decode-wrapped.js b/benchmark/buffers/buffer-base64-decode-wrapped.js index aa070ab55c44de..3140cd5525ad07 100644 --- a/benchmark/buffers/buffer-base64-decode-wrapped.js +++ b/benchmark/buffers/buffer-base64-decode-wrapped.js @@ -12,7 +12,7 @@ function main(conf) { const linesCount = 8 << 16; const bytesCount = charsPerLine * linesCount / 4 * 3; - const line = 'abcd'.repeat(charsPerLine / 4) + '\n'; + const line = `${'abcd'.repeat(charsPerLine / 4)}\n`; const data = line.repeat(linesCount); // eslint-disable-next-line no-unescaped-regexp-dot data.match(/./); // Flatten the string diff --git a/benchmark/buffers/buffer-bytelength.js b/benchmark/buffers/buffer-bytelength.js index f24bc5bc2907a9..44b0f9e389cdb7 100644 --- a/benchmark/buffers/buffer-bytelength.js +++ b/benchmark/buffers/buffer-bytelength.js @@ -28,7 +28,7 @@ function main(conf) { } else { for (var string of chars) { // Strings must be built differently, depending on encoding - var data = buildString(string, len); + var data = string.repeat(len); if (encoding === 'utf8') { strings.push(data); } else if (encoding === 'base64') { @@ -54,9 +54,3 @@ function main(conf) { } bench.end(n); } - -function buildString(str, times) { - if (times === 1) return str; - - return str + buildString(str, times - 1); -} diff --git a/benchmark/buffers/buffer-read.js b/benchmark/buffers/buffer-read.js index d23bd029f8bd44..30f3ff05adb15a 100644 --- a/benchmark/buffers/buffer-read.js +++ b/benchmark/buffers/buffer-read.js @@ -30,14 +30,14 @@ function main(conf) { var len = +conf.millions * 1e6; var clazz = conf.buf === 'fast' ? Buffer : require('buffer').SlowBuffer; var buff = new clazz(8); - var fn = 'read' + conf.type; + var fn = `read${conf.type}`; buff.writeDoubleLE(0, 0, noAssert); - var testFunction = new Function('buff', [ - 'for (var i = 0; i !== ' + len + '; i++) {', - ' buff.' + fn + '(0, ' + JSON.stringify(noAssert) + ');', - '}' - ].join('\n')); + var testFunction = new Function('buff', ` + for (var i = 0; i !== ${len}; i++) { + buff.${fn}(0, ${JSON.stringify(noAssert)}); + } + `); bench.start(); testFunction(buff); bench.end(len / 1e6); diff --git a/benchmark/buffers/buffer-swap.js b/benchmark/buffers/buffer-swap.js index 71e08890910843..9e36985f5cd209 100644 --- a/benchmark/buffers/buffer-swap.js +++ b/benchmark/buffers/buffer-swap.js @@ -64,11 +64,11 @@ function createBuffer(len, aligned) { } function genMethod(method) { - const fnString = - 'return function ' + method + '(n, buf) {' + - ' for (var i = 0; i <= n; i++)' + - ' buf.' + method + '();' + - '}'; + const fnString = ` + return function ${method}(n, buf) { + for (var i = 0; i <= n; i++) + buf.${method}(); + }`; return (new Function(fnString))(); } diff --git a/benchmark/buffers/buffer-write.js b/benchmark/buffers/buffer-write.js index 32c733045335cd..758c8b8b514e3f 100644 --- a/benchmark/buffers/buffer-write.js +++ b/benchmark/buffers/buffer-write.js @@ -50,7 +50,7 @@ function main(conf) { var len = +conf.millions * 1e6; var clazz = conf.buf === 'fast' ? Buffer : require('buffer').SlowBuffer; var buff = new clazz(8); - var fn = 'write' + conf.type; + var fn = `write${conf.type}`; if (fn.match(/Int/)) benchInt(buff, fn, len, noAssert); @@ -60,22 +60,22 @@ function main(conf) { function benchInt(buff, fn, len, noAssert) { var m = mod[fn]; - var testFunction = new Function('buff', [ - 'for (var i = 0; i !== ' + len + '; i++) {', - ' buff.' + fn + '(i & ' + m + ', 0, ' + JSON.stringify(noAssert) + ');', - '}' - ].join('\n')); + var testFunction = new Function('buff', ` + for (var i = 0; i !== ${len}; i++) { + buff.${fn}(i & ${m}, 0, ${JSON.stringify(noAssert)}); + } + `); bench.start(); testFunction(buff); bench.end(len / 1e6); } function benchFloat(buff, fn, len, noAssert) { - var testFunction = new Function('buff', [ - 'for (var i = 0; i !== ' + len + '; i++) {', - ' buff.' + fn + '(i, 0, ' + JSON.stringify(noAssert) + ');', - '}' - ].join('\n')); + var testFunction = new Function('buff', ` + for (var i = 0; i !== ${len}; i++) { + buff.${fn}(i, 0, ${JSON.stringify(noAssert)}); + } + `); bench.start(); testFunction(buff); bench.end(len / 1e6); diff --git a/benchmark/buffers/dataview-set.js b/benchmark/buffers/dataview-set.js index 717a77de71d641..16b2628842a4a4 100644 --- a/benchmark/buffers/dataview-set.js +++ b/benchmark/buffers/dataview-set.js @@ -44,7 +44,7 @@ function main(conf) { var ab = new ArrayBuffer(8); var dv = new DataView(ab, 0, 8); var le = /LE$/.test(conf.type); - var fn = 'set' + conf.type.replace(/[LB]E$/, ''); + var fn = `set${conf.type.replace(/[LB]E$/, '')}`; if (/int/i.test(fn)) benchInt(dv, fn, len, le); diff --git a/benchmark/common.js b/benchmark/common.js index 50c8e21244fb45..fc47a3ce025065 100644 --- a/benchmark/common.js +++ b/benchmark/common.js @@ -44,7 +44,7 @@ Benchmark.prototype._parseArgs = function(argv, configs) { for (const arg of argv) { const match = arg.match(/^(.+?)=([\s\S]*)$/); if (!match) { - console.error('bad argument: ' + arg); + console.error(`bad argument: ${arg}`); process.exit(1); } const config = match[1]; @@ -206,7 +206,7 @@ function formatResult(data) { // Construct configuration string, " A=a, B=b, ..." let conf = ''; for (const key of Object.keys(data.conf)) { - conf += ' ' + key + '=' + JSON.stringify(data.conf[key]); + conf += ` ${key}=${JSON.stringify(data.conf[key])}`; } var rate = data.rate.toString().split('.'); diff --git a/benchmark/compare.js b/benchmark/compare.js index 4d183a10e2b97d..aa6ddb72c0d054 100644 --- a/benchmark/compare.js +++ b/benchmark/compare.js @@ -79,14 +79,14 @@ if (showProgress) { // Construct configuration string, " A=a, B=b, ..." let conf = ''; for (const key of Object.keys(data.conf)) { - conf += ' ' + key + '=' + JSON.stringify(data.conf[key]); + conf += ` ${key}=${JSON.stringify(data.conf[key])}`; } conf = conf.slice(1); // Escape quotes (") for correct csv formatting conf = conf.replace(/"/g, '""'); - console.log(`"${job.binary}", "${job.filename}", "${conf}", ` + - `${data.rate}, ${data.time}`); + console.log(`"${job.binary}", "${job.filename}", "${conf}", ${ + data.rate}, ${data.time}`); if (showProgress) { // One item in the subqueue has been completed. progress.completeConfig(data); diff --git a/benchmark/crypto/cipher-stream.js b/benchmark/crypto/cipher-stream.js index 03780ba130717e..90bf548c76cdbb 100644 --- a/benchmark/crypto/cipher-stream.js +++ b/benchmark/crypto/cipher-stream.js @@ -51,7 +51,7 @@ function main(conf) { message = Buffer.alloc(conf.len, 'b'); break; default: - throw new Error('unknown message type: ' + conf.type); + throw new Error(`unknown message type: ${conf.type}`); } var fn = api === 'stream' ? streamWrite : legacyWrite; diff --git a/benchmark/crypto/hash-stream-creation.js b/benchmark/crypto/hash-stream-creation.js index 3be09785acbd30..296127ab3846e2 100644 --- a/benchmark/crypto/hash-stream-creation.js +++ b/benchmark/crypto/hash-stream-creation.js @@ -36,7 +36,7 @@ function main(conf) { message = Buffer.alloc(conf.len, 'b'); break; default: - throw new Error('unknown message type: ' + conf.type); + throw new Error(`unknown message type: ${conf.type}`); } var fn = api === 'stream' ? streamWrite : legacyWrite; diff --git a/benchmark/crypto/hash-stream-throughput.js b/benchmark/crypto/hash-stream-throughput.js index bf426fc2c91788..dbb2e5c99958d3 100644 --- a/benchmark/crypto/hash-stream-throughput.js +++ b/benchmark/crypto/hash-stream-throughput.js @@ -35,7 +35,7 @@ function main(conf) { message = Buffer.alloc(conf.len, 'b'); break; default: - throw new Error('unknown message type: ' + conf.type); + throw new Error(`unknown message type: ${conf.type}`); } var fn = api === 'stream' ? streamWrite : legacyWrite; diff --git a/benchmark/crypto/rsa-encrypt-decrypt-throughput.js b/benchmark/crypto/rsa-encrypt-decrypt-throughput.js index 4d98f9e2d5d859..b1fc3393667e99 100644 --- a/benchmark/crypto/rsa-encrypt-decrypt-throughput.js +++ b/benchmark/crypto/rsa-encrypt-decrypt-throughput.js @@ -10,10 +10,10 @@ var RSA_PublicPem = {}; var RSA_PrivatePem = {}; keylen_list.forEach(function(key) { - RSA_PublicPem[key] = fs.readFileSync(fixtures_keydir + - '/rsa_public_' + key + '.pem'); - RSA_PrivatePem[key] = fs.readFileSync(fixtures_keydir + - '/rsa_private_' + key + '.pem'); + RSA_PublicPem[key] = + fs.readFileSync(`${fixtures_keydir}/rsa_public_${key}.pem`); + RSA_PrivatePem[key] = + fs.readFileSync(`${fixtures_keydir}/rsa_private_${key}.pem`); }); var bench = common.createBenchmark(main, { diff --git a/benchmark/crypto/rsa-sign-verify-throughput.js b/benchmark/crypto/rsa-sign-verify-throughput.js index c5db94687a1aac..f13dc2585a7227 100644 --- a/benchmark/crypto/rsa-sign-verify-throughput.js +++ b/benchmark/crypto/rsa-sign-verify-throughput.js @@ -10,10 +10,10 @@ var RSA_PublicPem = {}; var RSA_PrivatePem = {}; keylen_list.forEach(function(key) { - RSA_PublicPem[key] = fs.readFileSync(fixtures_keydir + - '/rsa_public_' + key + '.pem'); - RSA_PrivatePem[key] = fs.readFileSync(fixtures_keydir + - '/rsa_private_' + key + '.pem'); + RSA_PublicPem[key] = + fs.readFileSync(`${fixtures_keydir}/rsa_public_${key}.pem`); + RSA_PrivatePem[key] = + fs.readFileSync(`${fixtures_keydir}/rsa_private_${key}.pem`); }); var bench = common.createBenchmark(main, { diff --git a/benchmark/es/map-bench.js b/benchmark/es/map-bench.js index 4663d71bdd3186..62ff332fd44149 100644 --- a/benchmark/es/map-bench.js +++ b/benchmark/es/map-bench.js @@ -16,11 +16,11 @@ function runObject(n) { var i = 0; bench.start(); for (; i < n; i++) { - m['i' + i] = i; - m['s' + i] = String(i); - assert.strictEqual(String(m['i' + i]), m['s' + i]); - m['i' + i] = undefined; - m['s' + i] = undefined; + m[`i${i}`] = i; + m[`s${i}`] = String(i); + assert.strictEqual(String(m[`i${i}`]), m[`s${i}`]); + m[`i${i}`] = undefined; + m[`s${i}`] = undefined; } bench.end(n / 1e6); } @@ -30,11 +30,11 @@ function runNullProtoObject(n) { var i = 0; bench.start(); for (; i < n; i++) { - m['i' + i] = i; - m['s' + i] = String(i); - assert.strictEqual(String(m['i' + i]), m['s' + i]); - m['i' + i] = undefined; - m['s' + i] = undefined; + m[`i${i}`] = i; + m[`s${i}`] = String(i); + assert.strictEqual(String(m[`i${i}`]), m[`s${i}`]); + m[`i${i}`] = undefined; + m[`s${i}`] = undefined; } bench.end(n / 1e6); } @@ -44,11 +44,11 @@ function runNullProtoLiteralObject(n) { var i = 0; bench.start(); for (; i < n; i++) { - m['i' + i] = i; - m['s' + i] = String(i); - assert.strictEqual(String(m['i' + i]), m['s' + i]); - m['i' + i] = undefined; - m['s' + i] = undefined; + m[`i${i}`] = i; + m[`s${i}`] = String(i); + assert.strictEqual(String(m[`i${i}`]), m[`s${i}`]); + m[`i${i}`] = undefined; + m[`s${i}`] = undefined; } bench.end(n / 1e6); } @@ -61,11 +61,11 @@ function runStorageObject(n) { var i = 0; bench.start(); for (; i < n; i++) { - m['i' + i] = i; - m['s' + i] = String(i); - assert.strictEqual(String(m['i' + i]), m['s' + i]); - m['i' + i] = undefined; - m['s' + i] = undefined; + m[`i${i}`] = i; + m[`s${i}`] = String(i); + assert.strictEqual(String(m[`i${i}`]), m[`s${i}`]); + m[`i${i}`] = undefined; + m[`s${i}`] = undefined; } bench.end(n / 1e6); } @@ -73,10 +73,10 @@ function runStorageObject(n) { function fakeMap() { const m = {}; return { - get(key) { return m['$' + key]; }, - set(key, val) { m['$' + key] = val; }, + get(key) { return m[`$${key}`]; }, + set(key, val) { m[`$${key}`] = val; }, get size() { return Object.keys(m).length; }, - has(key) { return Object.prototype.hasOwnProperty.call(m, '$' + key); } + has(key) { return Object.prototype.hasOwnProperty.call(m, `$${key}`); } }; } @@ -85,11 +85,11 @@ function runFakeMap(n) { var i = 0; bench.start(); for (; i < n; i++) { - m.set('i' + i, i); - m.set('s' + i, String(i)); - assert.strictEqual(String(m.get('i' + i)), m.get('s' + i)); - m.set('i' + i, undefined); - m.set('s' + i, undefined); + m.set(`i${i}`, i); + m.set(`s${i}`, String(i)); + assert.strictEqual(String(m.get(`i${i}`)), m.get(`s${i}`)); + m.set(`i${i}`, undefined); + m.set(`s${i}`, undefined); } bench.end(n / 1e6); } @@ -99,11 +99,11 @@ function runMap(n) { var i = 0; bench.start(); for (; i < n; i++) { - m.set('i' + i, i); - m.set('s' + i, String(i)); - assert.strictEqual(String(m.get('i' + i)), m.get('s' + i)); - m.set('i' + i, undefined); - m.set('s' + i, undefined); + m.set(`i${i}`, i); + m.set(`s${i}`, String(i)); + assert.strictEqual(String(m.get(`i${i}`)), m.get(`s${i}`)); + m.set(`i${i}`, undefined); + m.set(`s${i}`, undefined); } bench.end(n / 1e6); } diff --git a/benchmark/fs/bench-realpath.js b/benchmark/fs/bench-realpath.js index 384276eafff9b3..d6818d45a59fab 100644 --- a/benchmark/fs/bench-realpath.js +++ b/benchmark/fs/bench-realpath.js @@ -22,7 +22,7 @@ function main(conf) { else if (type === 'resolved') resolvedPath(n); else - throw new Error('unknown "type": ' + type); + throw new Error(`unknown "type": ${type}`); } function relativePath(n) { diff --git a/benchmark/fs/bench-realpathSync.js b/benchmark/fs/bench-realpathSync.js index bf1a38a746e150..27a66631ab3ebb 100644 --- a/benchmark/fs/bench-realpathSync.js +++ b/benchmark/fs/bench-realpathSync.js @@ -24,7 +24,7 @@ function main(conf) { else if (type === 'resolved') resolvedPath(n); else - throw new Error('unknown "type": ' + type); + throw new Error(`unknown "type": ${type}`); bench.end(n); } diff --git a/benchmark/http/_chunky_http_client.js b/benchmark/http/_chunky_http_client.js index 55f914c6df05f3..d235a5e04a0005 100644 --- a/benchmark/http/_chunky_http_client.js +++ b/benchmark/http/_chunky_http_client.js @@ -37,7 +37,7 @@ function main(conf) { for (var i = 0; i < extra_header_count; i++) { // Utilize first three powers of a small integer for an odd cycle and // because the fourth power of some integers overloads the server. - todo.push('X-Header-' + i + ': ' + headers[i % 3]); + todo.push(`X-Header-${i}: ${headers[i % 3]}`); } todo.push(''); todo.push(''); diff --git a/benchmark/http/cluster.js b/benchmark/http/cluster.js index 464bcfdb6311e4..3a9392c4229667 100644 --- a/benchmark/http/cluster.js +++ b/benchmark/http/cluster.js @@ -27,7 +27,7 @@ function main(conf) { return; setTimeout(function() { - var path = '/' + conf.type + '/' + conf.len; + var path = `/${conf.type}/${conf.len}`; bench.http({ path: path, diff --git a/benchmark/http/http_server_for_chunky_client.js b/benchmark/http/http_server_for_chunky_client.js index e58ba5f5a15cc7..bdeb517344d47d 100644 --- a/benchmark/http/http_server_for_chunky_client.js +++ b/benchmark/http/http_server_for_chunky_client.js @@ -6,7 +6,7 @@ var fs = require('fs'); var fork = require('child_process').fork; var common = require('../common.js'); var test = require('../../test/common.js'); -var pep = path.dirname(process.argv[1]) + '/_chunky_http_client.js'; +var pep = `${path.dirname(process.argv[1])}/_chunky_http_client.js`; var PIPE = test.PIPE; try { @@ -30,7 +30,7 @@ server = http.createServer(function(req, res) { }); server.on('error', function(err) { - throw new Error('server error: ' + err); + throw new Error(`server error: ${err}`); }); server.listen(PIPE); diff --git a/benchmark/http/simple.js b/benchmark/http/simple.js index c773e717913e99..81b7cb5afb2614 100644 --- a/benchmark/http/simple.js +++ b/benchmark/http/simple.js @@ -16,8 +16,7 @@ function main(conf) { var server = require('../fixtures/simple-http-server.js') .listen(process.env.PORT || common.PORT) .on('listening', function() { - var path = '/' + conf.type + '/' + conf.len + '/' + conf.chunks + '/' + - conf.res; + var path = `/${conf.type}/${conf.len}/${conf.chunks}/${conf.res}`; bench.http({ path: path, diff --git a/benchmark/misc/console.js b/benchmark/misc/console.js index 9c5aec0eeeb5fa..9c7c54859082cd 100644 --- a/benchmark/misc/console.js +++ b/benchmark/misc/console.js @@ -21,7 +21,7 @@ var bench = common.createBenchmark(main, { const nullStream = createNullStream(); function usingRestAndConcat(...args) { - nullStream.write('this is ' + args[0] + ' of ' + args[1] + '\n'); + nullStream.write(`this is ${args[0]} of ${args[1]}\n`); } function usingRestAndSpreadTS(...args) { @@ -37,15 +37,15 @@ function usingArgumentsAndApplyTS() { } function usingRestAndSpreadC(...args) { - nullStream.write(util.format(...args) + '\n'); + nullStream.write(`${util.format(...args)}\n`); } function usingRestAndApplyC(...args) { - nullStream.write(util.format.apply(null, args) + '\n'); + nullStream.write(`${util.format.apply(null, args)}\n`); } function usingArgumentsAndApplyC() { - nullStream.write(util.format.apply(null, arguments) + '\n'); + nullStream.write(`${util.format.apply(null, arguments)}\n`); } function runUsingRestAndConcat(n) { diff --git a/benchmark/misc/v8-bench.js b/benchmark/misc/v8-bench.js index 85c64b51fda1ef..97ff0c35c47e87 100644 --- a/benchmark/misc/v8-bench.js +++ b/benchmark/misc/v8-bench.js @@ -9,8 +9,8 @@ var dir = path.join(__dirname, '..', '..', 'deps', 'v8', 'benchmarks'); function load(filename, inGlobal) { var source = fs.readFileSync(path.join(dir, filename), 'utf8'); - if (!inGlobal) source = '(function () {' + source + '\n})()'; - vm.runInThisContext(source, { filename: 'v8/bechmark/' + filename }); + if (!inGlobal) source = `(function () {${source}\n})()`; + vm.runInThisContext(source, { filename: `v8/bechmark/${filename}` }); } load('base.js', true); @@ -41,13 +41,13 @@ global.BenchmarkSuite.RunSuites({ }); }, NotifyError: function(name, error) { - console.error(name + ': ' + error); + console.error(`${name}: ${error}`); }, NotifyScore: function(score) { common.sendResult({ name: benchmark_name, conf: { - benchmark: 'Score (version ' + global.BenchmarkSuite.version + ')' + benchmark: `Score (version ${global.BenchmarkSuite.version})` }, rate: score, time: 0 diff --git a/benchmark/module/module-loader.js b/benchmark/module/module-loader.js index d7e03cfee4dc41..7c72ac1d5c6559 100644 --- a/benchmark/module/module-loader.js +++ b/benchmark/module/module-loader.js @@ -20,13 +20,13 @@ function main(conf) { try { fs.mkdirSync(benchmarkDirectory); } catch (e) {} for (var i = 0; i <= n; i++) { - fs.mkdirSync(benchmarkDirectory + i); + fs.mkdirSync(`${benchmarkDirectory}${i}`); fs.writeFileSync( - benchmarkDirectory + i + '/package.json', + `${benchmarkDirectory}${i}/package.json`, '{"main": "index.js"}' ); fs.writeFileSync( - benchmarkDirectory + i + '/index.js', + `${benchmarkDirectory}${i}/index.js`, 'module.exports = "";' ); } @@ -43,12 +43,12 @@ function measureFull(n, useCache) { var i; if (useCache) { for (i = 0; i <= n; i++) { - require(benchmarkDirectory + i + '/index.js'); + require(`${benchmarkDirectory}${i}/index.js`); } } bench.start(); for (i = 0; i <= n; i++) { - require(benchmarkDirectory + i + '/index.js'); + require(`${benchmarkDirectory}${i}/index.js`); } bench.end(n / 1e3); } @@ -57,12 +57,12 @@ function measureDir(n, useCache) { var i; if (useCache) { for (i = 0; i <= n; i++) { - require(benchmarkDirectory + i); + require(`${benchmarkDirectory}${i}`); } } bench.start(); for (i = 0; i <= n; i++) { - require(benchmarkDirectory + i); + require(`${benchmarkDirectory}${i}`); } bench.end(n / 1e3); } diff --git a/benchmark/net/net-c2s-cork.js b/benchmark/net/net-c2s-cork.js index 4a119e9c275224..51ad09ae9e52db 100644 --- a/benchmark/net/net-c2s-cork.js +++ b/benchmark/net/net-c2s-cork.js @@ -34,7 +34,7 @@ function main(conf) { chunk = 'x'.repeat(len); break; default: - throw new Error('invalid type: ' + type); + throw new Error(`invalid type: ${type}`); } server(); diff --git a/benchmark/net/net-c2s.js b/benchmark/net/net-c2s.js index fdc5cfc5c77cee..4bbea92121ac0a 100644 --- a/benchmark/net/net-c2s.js +++ b/benchmark/net/net-c2s.js @@ -34,7 +34,7 @@ function main(conf) { chunk = 'x'.repeat(len); break; default: - throw new Error('invalid type: ' + type); + throw new Error(`invalid type: ${type}`); } server(); diff --git a/benchmark/net/net-pipe.js b/benchmark/net/net-pipe.js index d40da7e5497543..507640f8cea236 100644 --- a/benchmark/net/net-pipe.js +++ b/benchmark/net/net-pipe.js @@ -34,7 +34,7 @@ function main(conf) { chunk = 'x'.repeat(len); break; default: - throw new Error('invalid type: ' + type); + throw new Error(`invalid type: ${type}`); } server(); diff --git a/benchmark/net/net-s2c.js b/benchmark/net/net-s2c.js index 1c104e3417851d..9148a66f3af18f 100644 --- a/benchmark/net/net-s2c.js +++ b/benchmark/net/net-s2c.js @@ -34,7 +34,7 @@ function main(conf) { chunk = 'x'.repeat(len); break; default: - throw new Error('invalid type: ' + type); + throw new Error(`invalid type: ${type}`); } server(); diff --git a/benchmark/net/tcp-raw-c2s.js b/benchmark/net/tcp-raw-c2s.js index 8c9eff76e92216..87c6d5ec7e0ee7 100644 --- a/benchmark/net/tcp-raw-c2s.js +++ b/benchmark/net/tcp-raw-c2s.js @@ -89,7 +89,7 @@ function client() { chunk = 'x'.repeat(len); break; default: - throw new Error('invalid type: ' + type); + throw new Error(`invalid type: ${type}`); } var clientHandle = new TCP(); diff --git a/benchmark/net/tcp-raw-pipe.js b/benchmark/net/tcp-raw-pipe.js index 77d3553062ddae..c6d319c64dd380 100644 --- a/benchmark/net/tcp-raw-pipe.js +++ b/benchmark/net/tcp-raw-pipe.js @@ -86,7 +86,7 @@ function client() { chunk = 'x'.repeat(len); break; default: - throw new Error('invalid type: ' + type); + throw new Error(`invalid type: ${type}`); } var clientHandle = new TCP(); diff --git a/benchmark/net/tcp-raw-s2c.js b/benchmark/net/tcp-raw-s2c.js index 1cb0fb63f443f4..1c518a5c7fe426 100644 --- a/benchmark/net/tcp-raw-s2c.js +++ b/benchmark/net/tcp-raw-s2c.js @@ -60,7 +60,7 @@ function server() { chunk = 'x'.repeat(len); break; default: - throw new Error('invalid type: ' + type); + throw new Error(`invalid type: ${type}`); } clientHandle.readStart(); diff --git a/benchmark/path/basename-posix.js b/benchmark/path/basename-posix.js index fc983c8074c940..10465b2c734a10 100644 --- a/benchmark/path/basename-posix.js +++ b/benchmark/path/basename-posix.js @@ -21,7 +21,7 @@ var bench = common.createBenchmark(main, { function main(conf) { var n = +conf.n; var p = path.posix; - var input = '' + conf.pathext; + var input = String(conf.pathext); var ext; var extIdx = input.indexOf('|'); if (extIdx !== -1) { diff --git a/benchmark/path/basename-win32.js b/benchmark/path/basename-win32.js index b493beb87c9e94..77bf326ed2bc84 100644 --- a/benchmark/path/basename-win32.js +++ b/benchmark/path/basename-win32.js @@ -21,7 +21,7 @@ var bench = common.createBenchmark(main, { function main(conf) { var n = +conf.n; var p = path.win32; - var input = '' + conf.pathext; + var input = String(conf.pathext); var ext; var extIdx = input.indexOf('|'); if (extIdx !== -1) { diff --git a/benchmark/path/dirname-posix.js b/benchmark/path/dirname-posix.js index af77be5ac06559..a72aceb89ee7f9 100644 --- a/benchmark/path/dirname-posix.js +++ b/benchmark/path/dirname-posix.js @@ -18,7 +18,7 @@ var bench = common.createBenchmark(main, { function main(conf) { var n = +conf.n; var p = path.posix; - var input = '' + conf.path; + var input = String(conf.path); bench.start(); for (var i = 0; i < n; i++) { diff --git a/benchmark/path/dirname-win32.js b/benchmark/path/dirname-win32.js index 01d97d08e2ae05..11a89073e6e9c9 100644 --- a/benchmark/path/dirname-win32.js +++ b/benchmark/path/dirname-win32.js @@ -18,7 +18,7 @@ var bench = common.createBenchmark(main, { function main(conf) { var n = +conf.n; var p = path.win32; - var input = '' + conf.path; + var input = String(conf.path); bench.start(); for (var i = 0; i < n; i++) { diff --git a/benchmark/path/extname-posix.js b/benchmark/path/extname-posix.js index 50c4e8f7927ba6..25d53d08e190dc 100644 --- a/benchmark/path/extname-posix.js +++ b/benchmark/path/extname-posix.js @@ -21,7 +21,7 @@ var bench = common.createBenchmark(main, { function main(conf) { var n = +conf.n; var p = path.posix; - var input = '' + conf.path; + var input = String(conf.path); bench.start(); for (var i = 0; i < n; i++) { diff --git a/benchmark/path/extname-win32.js b/benchmark/path/extname-win32.js index 9c0df13ab46105..d4a4638a68b842 100644 --- a/benchmark/path/extname-win32.js +++ b/benchmark/path/extname-win32.js @@ -21,7 +21,7 @@ var bench = common.createBenchmark(main, { function main(conf) { var n = +conf.n; var p = path.win32; - var input = '' + conf.path; + var input = String(conf.path); bench.start(); for (var i = 0; i < n; i++) { diff --git a/benchmark/path/format-posix.js b/benchmark/path/format-posix.js index ee78a6d5f30980..04f62077757921 100644 --- a/benchmark/path/format-posix.js +++ b/benchmark/path/format-posix.js @@ -12,7 +12,7 @@ var bench = common.createBenchmark(main, { function main(conf) { var n = +conf.n; var p = path.posix; - var props = ('' + conf.props).split('|'); + var props = String(conf.props).split('|'); var obj = { root: props[0] || '', dir: props[1] || '', diff --git a/benchmark/path/format-win32.js b/benchmark/path/format-win32.js index 9ec981d6310ed6..189fe9c34ff5b1 100644 --- a/benchmark/path/format-win32.js +++ b/benchmark/path/format-win32.js @@ -12,7 +12,7 @@ var bench = common.createBenchmark(main, { function main(conf) { var n = +conf.n; var p = path.win32; - var props = ('' + conf.props).split('|'); + var props = String(conf.props).split('|'); var obj = { root: props[0] || '', dir: props[1] || '', diff --git a/benchmark/path/isAbsolute-posix.js b/benchmark/path/isAbsolute-posix.js index 22db751100ceee..cff04746543fd6 100644 --- a/benchmark/path/isAbsolute-posix.js +++ b/benchmark/path/isAbsolute-posix.js @@ -16,7 +16,7 @@ var bench = common.createBenchmark(main, { function main(conf) { var n = +conf.n; var p = path.posix; - var input = '' + conf.path; + var input = String(conf.path); bench.start(); for (var i = 0; i < n; i++) { diff --git a/benchmark/path/isAbsolute-win32.js b/benchmark/path/isAbsolute-win32.js index a565da8e566f8f..0eeeb64531720a 100644 --- a/benchmark/path/isAbsolute-win32.js +++ b/benchmark/path/isAbsolute-win32.js @@ -17,7 +17,7 @@ var bench = common.createBenchmark(main, { function main(conf) { var n = +conf.n; var p = path.win32; - var input = '' + conf.path; + var input = String(conf.path); bench.start(); for (var i = 0; i < n; i++) { diff --git a/benchmark/path/join-posix.js b/benchmark/path/join-posix.js index a7cf3772522daa..326789bf390439 100644 --- a/benchmark/path/join-posix.js +++ b/benchmark/path/join-posix.js @@ -12,7 +12,7 @@ var bench = common.createBenchmark(main, { function main(conf) { var n = +conf.n; var p = path.posix; - var args = ('' + conf.paths).split('|'); + var args = String(conf.paths).split('|'); bench.start(); for (var i = 0; i < n; i++) { diff --git a/benchmark/path/join-win32.js b/benchmark/path/join-win32.js index 18c1e802a6bff1..5042d270e11db7 100644 --- a/benchmark/path/join-win32.js +++ b/benchmark/path/join-win32.js @@ -12,7 +12,7 @@ var bench = common.createBenchmark(main, { function main(conf) { var n = +conf.n; var p = path.win32; - var args = ('' + conf.paths).split('|'); + var args = String(conf.paths).split('|'); bench.start(); for (var i = 0; i < n; i++) { diff --git a/benchmark/path/makeLong-win32.js b/benchmark/path/makeLong-win32.js index fe5da425a5cd73..0cc6c66204447c 100644 --- a/benchmark/path/makeLong-win32.js +++ b/benchmark/path/makeLong-win32.js @@ -15,7 +15,7 @@ var bench = common.createBenchmark(main, { function main(conf) { var n = +conf.n; var p = path.win32; - var input = '' + conf.path; + var input = String(conf.path); bench.start(); for (var i = 0; i < n; i++) { diff --git a/benchmark/path/normalize-posix.js b/benchmark/path/normalize-posix.js index aec703cbe21242..541f7b9112e5f6 100644 --- a/benchmark/path/normalize-posix.js +++ b/benchmark/path/normalize-posix.js @@ -17,7 +17,7 @@ var bench = common.createBenchmark(main, { function main(conf) { var n = +conf.n; var p = path.posix; - var input = '' + conf.path; + var input = String(conf.path); bench.start(); for (var i = 0; i < n; i++) { diff --git a/benchmark/path/normalize-win32.js b/benchmark/path/normalize-win32.js index 356d399c3513ab..3af2aca4344457 100644 --- a/benchmark/path/normalize-win32.js +++ b/benchmark/path/normalize-win32.js @@ -17,7 +17,7 @@ var bench = common.createBenchmark(main, { function main(conf) { var n = +conf.n; var p = path.win32; - var input = '' + conf.path; + var input = String(conf.path); bench.start(); for (var i = 0; i < n; i++) { diff --git a/benchmark/path/parse-posix.js b/benchmark/path/parse-posix.js index 997eec0452b74a..0130c16aa58444 100644 --- a/benchmark/path/parse-posix.js +++ b/benchmark/path/parse-posix.js @@ -18,7 +18,7 @@ var bench = common.createBenchmark(main, { function main(conf) { var n = +conf.n; var p = path.posix; - var input = '' + conf.path; + var input = String(conf.path); for (var i = 0; i < n; i++) { p.parse(input); diff --git a/benchmark/path/parse-win32.js b/benchmark/path/parse-win32.js index 2a95f758665377..fbcff5fd68b833 100644 --- a/benchmark/path/parse-win32.js +++ b/benchmark/path/parse-win32.js @@ -19,7 +19,7 @@ var bench = common.createBenchmark(main, { function main(conf) { var n = +conf.n; var p = path.win32; - var input = '' + conf.path; + var input = String(conf.path); for (var i = 0; i < n; i++) { p.parse(input); diff --git a/benchmark/path/relative-posix.js b/benchmark/path/relative-posix.js index 492b73c3e89f8a..3fb6dc9ee13f73 100644 --- a/benchmark/path/relative-posix.js +++ b/benchmark/path/relative-posix.js @@ -18,7 +18,7 @@ var bench = common.createBenchmark(main, { function main(conf) { var n = +conf.n; var p = path.posix; - var from = '' + conf.paths; + var from = String(conf.paths); var to = ''; var delimIdx = from.indexOf('|'); if (delimIdx > -1) { diff --git a/benchmark/path/relative-win32.js b/benchmark/path/relative-win32.js index 7e7620299eb16c..fafda6d1ce46c4 100644 --- a/benchmark/path/relative-win32.js +++ b/benchmark/path/relative-win32.js @@ -16,7 +16,7 @@ var bench = common.createBenchmark(main, { function main(conf) { var n = +conf.n; var p = path.win32; - var from = '' + conf.paths; + var from = String(conf.paths); var to = ''; var delimIdx = from.indexOf('|'); if (delimIdx > -1) { diff --git a/benchmark/path/resolve-posix.js b/benchmark/path/resolve-posix.js index d1364a8ac256c9..61b809b6664dc8 100644 --- a/benchmark/path/resolve-posix.js +++ b/benchmark/path/resolve-posix.js @@ -15,7 +15,7 @@ var bench = common.createBenchmark(main, { function main(conf) { var n = +conf.n; var p = path.posix; - var args = ('' + conf.paths).split('|'); + var args = String(conf.paths).split('|'); bench.start(); for (var i = 0; i < n; i++) { diff --git a/benchmark/path/resolve-win32.js b/benchmark/path/resolve-win32.js index 6dfb38167c96bd..ccfeec696d9b3d 100644 --- a/benchmark/path/resolve-win32.js +++ b/benchmark/path/resolve-win32.js @@ -15,7 +15,7 @@ var bench = common.createBenchmark(main, { function main(conf) { var n = +conf.n; var p = path.win32; - var args = ('' + conf.paths).split('|'); + var args = String(conf.paths).split('|'); bench.start(); for (var i = 0; i < n; i++) { diff --git a/benchmark/run.js b/benchmark/run.js index cb4f8cc00487fe..3b4944caf5ce97 100644 --- a/benchmark/run.js +++ b/benchmark/run.js @@ -50,7 +50,7 @@ if (format === 'csv') { // Construct configuration string, " A=a, B=b, ..." let conf = ''; for (const key of Object.keys(data.conf)) { - conf += ' ' + key + '=' + JSON.stringify(data.conf[key]); + conf += ` ${key}=${JSON.stringify(data.conf[key])}`; } // delete first space of the configuration conf = conf.slice(1); diff --git a/benchmark/scatter.js b/benchmark/scatter.js index 65d1a5f604877d..306d06132f3254 100644 --- a/benchmark/scatter.js +++ b/benchmark/scatter.js @@ -34,7 +34,7 @@ function csvEncodeValue(value) { if (typeof value === 'number') { return value.toString(); } else { - return '"' + value.replace(/"/g, '""') + '"'; + return `"${value.replace(/"/g, '""')}"`; } } diff --git a/benchmark/timers/timers-cancel-unpooled.js b/benchmark/timers/timers-cancel-unpooled.js index a040fad69e1c66..14cbad8256a634 100644 --- a/benchmark/timers/timers-cancel-unpooled.js +++ b/benchmark/timers/timers-cancel-unpooled.js @@ -22,5 +22,5 @@ function main(conf) { } function cb() { - assert(false, 'Timer ' + this._idleTimeout + ' should not call callback'); + assert(false, `Timer ${this._idleTimeout} should not call callback`); } diff --git a/benchmark/timers/timers-insert-unpooled.js b/benchmark/timers/timers-insert-unpooled.js index 91eabeb04e9d4f..bdcd7e0ff79f27 100644 --- a/benchmark/timers/timers-insert-unpooled.js +++ b/benchmark/timers/timers-insert-unpooled.js @@ -23,5 +23,5 @@ function main(conf) { } function cb() { - assert(false, 'Timer ' + this._idleTimeout + ' should not call callback'); + assert(false, `Timer ${this._idleTimeout} should not call callback`); } diff --git a/benchmark/tls/throughput.js b/benchmark/tls/throughput.js index c2b389fe45a7a4..2b8b2d537643a9 100644 --- a/benchmark/tls/throughput.js +++ b/benchmark/tls/throughput.js @@ -38,9 +38,9 @@ function main(conf) { } options = { - key: fs.readFileSync(cert_dir + '/test_key.pem'), - cert: fs.readFileSync(cert_dir + '/test_cert.pem'), - ca: [ fs.readFileSync(cert_dir + '/test_ca.pem') ], + key: fs.readFileSync(`${cert_dir}/test_key.pem`), + cert: fs.readFileSync(`${cert_dir}/test_cert.pem`), + ca: [ fs.readFileSync(`${cert_dir}/test_ca.pem`) ], ciphers: 'AES256-GCM-SHA384' }; diff --git a/benchmark/tls/tls-connect.js b/benchmark/tls/tls-connect.js index 5ca67f3230d3c8..3acc79e73acac8 100644 --- a/benchmark/tls/tls-connect.js +++ b/benchmark/tls/tls-connect.js @@ -22,9 +22,9 @@ function main(conf) { var cert_dir = path.resolve(__dirname, '../../test/fixtures'); var options = { - key: fs.readFileSync(cert_dir + '/test_key.pem'), - cert: fs.readFileSync(cert_dir + '/test_cert.pem'), - ca: [ fs.readFileSync(cert_dir + '/test_ca.pem') ], + key: fs.readFileSync(`${cert_dir}/test_key.pem`), + cert: fs.readFileSync(`${cert_dir}/test_cert.pem`), + ca: [ fs.readFileSync(`${cert_dir}/test_ca.pem`) ], ciphers: 'AES256-GCM-SHA384' }; diff --git a/benchmark/url/legacy-vs-whatwg-url-get-prop.js b/benchmark/url/legacy-vs-whatwg-url-get-prop.js index ffc8b4995df3de..733a05a17305e7 100644 --- a/benchmark/url/legacy-vs-whatwg-url-get-prop.js +++ b/benchmark/url/legacy-vs-whatwg-url-get-prop.js @@ -48,7 +48,7 @@ function useWHATWG(n, input) { var obj = new URL(input); var noDead = { protocol: obj.protocol, - auth: obj.username + ':' + obj.password, + auth: `${obj.username}:${obj.password}`, host: obj.host, hostname: obj.hostname, port: obj.port, @@ -59,7 +59,7 @@ function useWHATWG(n, input) { bench.start(); for (var i = 0; i < n; i += 1) { noDead.protocol = obj.protocol; - noDead.auth = obj.username + ':' + obj.password; + noDead.auth = `${obj.username}:${obj.password}`; noDead.host = obj.host; noDead.hostname = obj.hostname; noDead.port = obj.port;