Skip to content

Commit 4ecff6c

Browse files
Trottaddaleax
authored andcommitted
tools,benchmark: use stricter indentation linting
Enable stricter indentation rules for benchmark code. PR-URL: #13895 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent c732bf6 commit 4ecff6c

File tree

8 files changed

+36
-32
lines changed

8 files changed

+36
-32
lines changed

‎benchmark/.eslintrc.yaml‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## Benchmarks-specific linter rules
2+
3+
rules:
4+
# Stylistic Issues
5+
# http://eslint.org/docs/rules/#stylistic-issues
6+
indent: [2, 2,{ArrayExpression: first,
7+
CallExpression: {arguments: first},
8+
FunctionDeclaration: {parameters: first},
9+
FunctionExpression: {parameters: first},
10+
MemberExpression: off,
11+
ObjectExpression: first,
12+
SwitchCase: 1}]
13+
indent-legacy: 0

‎benchmark/_benchmark_progress.js‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ class BenchmarkProgress{
8787
construnsPerFile=this.runsPerFile;
8888
constcompletedFiles=Math.floor(completedRuns/runsPerFile);
8989
constscheduledFiles=this.benchmarks.length;
90-
constcompletedRunsForFile=finished ? runsPerFile :
91-
completedRuns%runsPerFile;
90+
constcompletedRunsForFile=
91+
finished ? runsPerFile :completedRuns%runsPerFile;
9292
constcompletedConfig=this.completedConfig;
9393
constscheduledConfig=this.scheduledConfig;
9494

@@ -101,12 +101,11 @@ class BenchmarkProgress{
101101
constpercent=pad(Math.floor(completedRate*100),3,' ');
102102

103103
constcaption=finished ? 'Done\n' : this.currentFile;
104-
return`[${getTime(diff)}|% ${
105-
percent}| ${
106-
fraction(completedFiles,scheduledFiles)} files | ${
107-
fraction(completedRunsForFile,runsPerFile)} runs | ${
108-
fraction(completedConfig,scheduledConfig)} configs]: ${
109-
caption} `;
104+
return`[${getTime(diff)}|% ${percent}| `+
105+
`${fraction(completedFiles,scheduledFiles)} files | `+
106+
`${fraction(completedRunsForFile,runsPerFile)} runs | `+
107+
`${fraction(completedConfig,scheduledConfig)} configs]: `+
108+
`${caption} `;
110109
}
111110

112111
updateProgress(finished){

‎benchmark/_http-benchmarkers.js‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ exports.PORT = process.env.PORT || 12346;
1313
classAutocannonBenchmarker{
1414
constructor(){
1515
this.name='autocannon';
16-
this.executable=process.platform==='win32' ?
17-
'autocannon.cmd' :
18-
'autocannon';
16+
this.executable=
17+
process.platform==='win32' ? 'autocannon.cmd' : 'autocannon';
1918
constresult=child_process.spawnSync(this.executable,['-h']);
2019
this.present=!(result.error&&result.error.code==='ENOENT');
2120
}
@@ -136,19 +135,19 @@ exports.run = function(options, callback){
136135
benchmarker: exports.default_http_benchmarker
137136
},options);
138137
if(!options.benchmarker){
139-
callback(newError(`Could not locate required http benchmarker. See ${
140-
requirementsURL} for further instructions.`));
138+
callback(newError('Could not locate required http benchmarker. See '+
139+
`${requirementsURL} for further instructions.`));
141140
return;
142141
}
143142
constbenchmarker=benchmarkers[options.benchmarker];
144143
if(!benchmarker){
145-
callback(newError(`Requested benchmarker '${
146-
options.benchmarker}' is not supported`));
144+
callback(newError(`Requested benchmarker '${options.benchmarker}' `+
145+
'is not supported'));
147146
return;
148147
}
149148
if(!benchmarker.present){
150-
callback(newError(`Requested benchmarker '${
151-
options.benchmarker}' is not installed`));
149+
callback(newError(`Requested benchmarker '${options.benchmarker}' `+
150+
'is not installed'));
152151
return;
153152
}
154153

‎benchmark/buffers/buffer-compare-offset.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ function compareUsingOffset(b0, b1, len, iter){
2626
functionmain(conf){
2727
constiter=(conf.millions>>>0)*1e6;
2828
constsize=(conf.size>>>0);
29-
constmethod=conf.method==='slice' ?
30-
compareUsingSlice : compareUsingOffset;
29+
constmethod=
30+
conf.method==='slice' ?compareUsingSlice : compareUsingOffset;
3131
method(Buffer.alloc(size,'a'),
3232
Buffer.alloc(size,'b'),
3333
size>>1,

‎benchmark/child_process/child-process-read-ipc.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if (process.argv[2] === 'child'){
2626

2727
constoptions={'stdio': ['ignore',1,2,'ipc']};
2828
constchild=spawn(process.argv[0],
29-
[process.argv[1],'child',len],options);
29+
[process.argv[1],'child',len],options);
3030

3131
varbytes=0;
3232
child.on('message',function(msg){

‎benchmark/compare.js‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ const cli = CLI(`usage: ./node compare.js [options] [--] <category> ...
2020
--filter pattern string to filter benchmark scripts
2121
--set variable=value set benchmark variable (can be repeated)
2222
--no-progress don't show benchmark progress indicator
23-
`,{
24-
arrayArgs: ['set'],
25-
boolArgs: ['no-progress']
26-
});
23+
`,{arrayArgs: ['set'],boolArgs: ['no-progress']});
2724

2825
if(!cli.optional.new||!cli.optional.old){
2926
cli.abort(cli.usage);
@@ -85,8 +82,8 @@ if (showProgress){
8582
// Escape quotes (") for correct csv formatting
8683
conf=conf.replace(/"/g,'""');
8784

88-
console.log(`"${job.binary}", "${job.filename}", "${conf}", ${
89-
data.rate}, ${data.time}`);
85+
console.log(`"${job.binary}", "${job.filename}", "${conf}", `+
86+
`${data.rate}, ${data.time}`);
9087
if(showProgress){
9188
// One item in the subqueue has been completed.
9289
progress.completeConfig(data);

‎benchmark/run.js‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ const cli = CLI(`usage: ./node run.js [options] [--] <category> ...
1111
--filter pattern string to filter benchmark scripts
1212
--set variable=value set benchmark variable (can be repeated)
1313
--format [simple|csv] optional value that specifies the output format
14-
`,{
15-
arrayArgs: ['set']
16-
});
14+
`,{arrayArgs: ['set']});
1715
constbenchmarks=cli.benchmarks();
1816

1917
if(benchmarks.length===0){

‎benchmark/scatter.js‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ const cli = CLI(`usage: ./node scatter.js [options] [--] <filename>
1313
1414
--runs 30 number of samples
1515
--set variable=value set benchmark variable (can be repeated)
16-
`,{
17-
arrayArgs: ['set']
18-
});
16+
`,{arrayArgs: ['set']});
1917

2018
if(cli.items.length!==1){
2119
cli.abort(cli.usage);

0 commit comments

Comments
(0)