diff options
author | Rich Trott <rtrott@gmail.com> | 2017-06-23 20:52:07 -0700 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2017-06-27 06:17:06 -0700 |
commit | 496f60489d774ff32e3136b99320963ad46eed98 (patch) | |
tree | d7663e20f5096fa684b5216bb86828db65a69d0f /benchmark | |
parent | 1e5e0ce862174b95fcc04d4b9f9ea68c5944bfee (diff) | |
download | node-new-496f60489d774ff32e3136b99320963ad46eed98.tar.gz |
tools,benchmark: use stricter indentation linting
Enable stricter indentation rules for benchmark code.
PR-URL: https://github.com/nodejs/node/pull/13895
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Diffstat (limited to 'benchmark')
-rw-r--r-- | benchmark/.eslintrc.yaml | 13 | ||||
-rw-r--r-- | benchmark/_benchmark_progress.js | 15 | ||||
-rw-r--r-- | benchmark/_http-benchmarkers.js | 17 | ||||
-rw-r--r-- | benchmark/buffers/buffer-compare-offset.js | 4 | ||||
-rw-r--r-- | benchmark/child_process/child-process-read-ipc.js | 2 | ||||
-rw-r--r-- | benchmark/compare.js | 9 | ||||
-rw-r--r-- | benchmark/run.js | 4 | ||||
-rw-r--r-- | benchmark/scatter.js | 4 |
8 files changed, 36 insertions, 32 deletions
diff --git a/benchmark/.eslintrc.yaml b/benchmark/.eslintrc.yaml new file mode 100644 index 0000000000..d569a63249 --- /dev/null +++ b/benchmark/.eslintrc.yaml @@ -0,0 +1,13 @@ +## Benchmarks-specific linter rules + +rules: + # Stylistic Issues + # http://eslint.org/docs/rules/#stylistic-issues + indent: [2, 2, {ArrayExpression: first, + CallExpression: {arguments: first}, + FunctionDeclaration: {parameters: first}, + FunctionExpression: {parameters: first}, + MemberExpression: off, + ObjectExpression: first, + SwitchCase: 1}] + indent-legacy: 0 diff --git a/benchmark/_benchmark_progress.js b/benchmark/_benchmark_progress.js index 5e2ae4ab11..0c5cc10bf8 100644 --- a/benchmark/_benchmark_progress.js +++ b/benchmark/_benchmark_progress.js @@ -87,8 +87,8 @@ class BenchmarkProgress { const runsPerFile = this.runsPerFile; const completedFiles = Math.floor(completedRuns / runsPerFile); const scheduledFiles = this.benchmarks.length; - const completedRunsForFile = finished ? runsPerFile : - completedRuns % runsPerFile; + const completedRunsForFile = + finished ? runsPerFile : completedRuns % runsPerFile; const completedConfig = this.completedConfig; const scheduledConfig = this.scheduledConfig; @@ -101,12 +101,11 @@ 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 bdc35308a7..3f17f05f83 100644 --- a/benchmark/_http-benchmarkers.js +++ b/benchmark/_http-benchmarkers.js @@ -13,9 +13,8 @@ exports.PORT = process.env.PORT || 12346; class AutocannonBenchmarker { constructor() { this.name = 'autocannon'; - this.executable = process.platform === 'win32' ? - 'autocannon.cmd' : - 'autocannon'; + this.executable = + process.platform === 'win32' ? 'autocannon.cmd' : 'autocannon'; const result = child_process.spawnSync(this.executable, ['-h']); this.present = !(result.error && result.error.code === 'ENOENT'); } @@ -136,19 +135,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 ${ - requirementsURL} 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; } diff --git a/benchmark/buffers/buffer-compare-offset.js b/benchmark/buffers/buffer-compare-offset.js index fd8c96dbce..96719abfbe 100644 --- a/benchmark/buffers/buffer-compare-offset.js +++ b/benchmark/buffers/buffer-compare-offset.js @@ -26,8 +26,8 @@ function compareUsingOffset(b0, b1, len, iter) { function main(conf) { const iter = (conf.millions >>> 0) * 1e6; const size = (conf.size >>> 0); - const method = conf.method === 'slice' ? - compareUsingSlice : compareUsingOffset; + const method = + conf.method === 'slice' ? compareUsingSlice : compareUsingOffset; method(Buffer.alloc(size, 'a'), Buffer.alloc(size, 'b'), size >> 1, diff --git a/benchmark/child_process/child-process-read-ipc.js b/benchmark/child_process/child-process-read-ipc.js index 30dead1803..e6fb9b19c2 100644 --- a/benchmark/child_process/child-process-read-ipc.js +++ b/benchmark/child_process/child-process-read-ipc.js @@ -26,7 +26,7 @@ if (process.argv[2] === 'child') { const options = { 'stdio': ['ignore', 1, 2, 'ipc'] }; const child = spawn(process.argv[0], - [process.argv[1], 'child', len], options); + [process.argv[1], 'child', len], options); var bytes = 0; child.on('message', function(msg) { diff --git a/benchmark/compare.js b/benchmark/compare.js index aa6ddb72c0..6b51a70eb9 100644 --- a/benchmark/compare.js +++ b/benchmark/compare.js @@ -20,10 +20,7 @@ const cli = CLI(`usage: ./node compare.js [options] [--] <category> ... --filter pattern string to filter benchmark scripts --set variable=value set benchmark variable (can be repeated) --no-progress don't show benchmark progress indicator -`, { - arrayArgs: ['set'], - boolArgs: ['no-progress'] -}); +`, { arrayArgs: ['set'], boolArgs: ['no-progress'] }); if (!cli.optional.new || !cli.optional.old) { cli.abort(cli.usage); @@ -85,8 +82,8 @@ if (showProgress) { // 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/run.js b/benchmark/run.js index 2b263a1a6c..af2bd4d5c2 100644 --- a/benchmark/run.js +++ b/benchmark/run.js @@ -11,9 +11,7 @@ const cli = CLI(`usage: ./node run.js [options] [--] <category> ... --filter pattern string to filter benchmark scripts --set variable=value set benchmark variable (can be repeated) --format [simple|csv] optional value that specifies the output format -`, { - arrayArgs: ['set'] -}); +`, { arrayArgs: ['set'] }); const benchmarks = cli.benchmarks(); if (benchmarks.length === 0) { diff --git a/benchmark/scatter.js b/benchmark/scatter.js index 306d06132f..70c3e25bb9 100644 --- a/benchmark/scatter.js +++ b/benchmark/scatter.js @@ -13,9 +13,7 @@ const cli = CLI(`usage: ./node scatter.js [options] [--] <filename> --runs 30 number of samples --set variable=value set benchmark variable (can be repeated) -`, { - arrayArgs: ['set'] -}); +`, { arrayArgs: ['set'] }); if (cli.items.length !== 1) { cli.abort(cli.usage); |