Skip to content

Commit dcfda10

Browse files
committed
tools,benchmark: increase lint compliance
In the hopes of soon having the benchmark code linted, this change groups all the likely non-controversial lint-compliance changes such as indentation, semi-colon usage, and single-vs.-double quotation marks. Other lint rules may have subtle performance implications in the V8 currently shipped with Node.js. Those changes will require more careful review and will be in a separate change. PR-URL: #5429 Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Brian White <mscdex@mscdex.net>
1 parent 7fc6645 commit dcfda10

49 files changed

Lines changed: 118 additions & 160 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎benchmark/buffers/buffer-bytelength.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function main(conf) {
4444
varr=Buffer.byteLength(strings[index],encoding);
4545

4646
if(r!==results[index])
47-
throwError('incorrect return value');
47+
thrownewError('incorrect return value');
4848
}
4949
bench.end(n);
5050
}

‎benchmark/buffers/buffer-read.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ function main(conf) {
2222

2323
buff.writeDoubleLE(0,0,noAssert);
2424
vartestFunction=newFunction('buff',[
25-
"for (var i = 0; i !== "+len+"; i++) {",
26-
" buff."+fn+"(0, "+JSON.stringify(noAssert)+");",
27-
"}"
28-
].join("\n"));
25+
'for (var i = 0; i !== '+len+'; i++) {',
26+
' buff.'+fn+'(0, '+JSON.stringify(noAssert)+');',
27+
'}'
28+
].join('\n'));
2929
bench.start();
3030
testFunction(buff);
3131
bench.end(len/1e6);

‎benchmark/buffers/buffer-write.js‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,21 @@ function main(conf) {
4848
functionbenchInt(buff,fn,len,noAssert){
4949
varm=mod[fn];
5050
vartestFunction=newFunction('buff',[
51-
"for (var i = 0; i !== "+len+"; i++) {",
52-
" buff."+fn+"(i & "+m+", 0, "+JSON.stringify(noAssert)+");",
53-
"}"
54-
].join("\n"));
51+
'for (var i = 0; i !== '+len+'; i++) {',
52+
' buff.'+fn+'(i & '+m+', 0, '+JSON.stringify(noAssert)+');',
53+
'}'
54+
].join('\n'));
5555
bench.start();
5656
testFunction(buff);
5757
bench.end(len/1e6);
5858
}
5959

6060
functionbenchFloat(buff,fn,len,noAssert){
6161
vartestFunction=newFunction('buff',[
62-
"for (var i = 0; i !== "+len+"; i++) {",
63-
" buff."+fn+"(i, 0, "+JSON.stringify(noAssert)+");",
64-
"}"
65-
].join("\n"));
62+
'for (var i = 0; i !== '+len+'; i++) {',
63+
' buff.'+fn+'(i, 0, '+JSON.stringify(noAssert)+');',
64+
'}'
65+
].join('\n'));
6666
bench.start();
6767
testFunction(buff);
6868
bench.end(len/1e6);

‎benchmark/common.js‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ if (module === require.main) {
2828
vartests=fs.readdirSync(dir);
2929

3030
if(testFilter){
31-
varfilteredTests=tests.filter(function(item){
31+
varfilteredTests=tests.filter(function(item){
3232
if(item.lastIndexOf(testFilter)>=0){
3333
returnitem;
3434
}
@@ -49,7 +49,7 @@ function hasWrk() {
4949
if(result.error&&result.error.code==='ENOENT'){
5050
console.error('Couldn\'t locate `wrk` which is needed for running '+
5151
'benchmarks. Check benchmark/README.md for further instructions.');
52-
process.exit(-1);
52+
process.exit(-1);
5353
}
5454
}
5555

@@ -87,7 +87,7 @@ function Benchmark(fn, options) {
8787
this.options=options;
8888
this.config=parseOpts(options);
8989
this._name=require.main.filename.split(/benchmark[\/\\]/).pop();
90-
this._start=[0,0];
90+
this._start=[0,0];
9191
this._started=false;
9292

9393
varself=this;
@@ -121,7 +121,7 @@ Benchmark.prototype.http = function(p, args, cb) {
121121

122122
if(code){
123123
console.error('wrk failed with '+code);
124-
process.exit(code)
124+
process.exit(code);
125125
}
126126
varmatch=out.match(regexp);
127127
varqps=match&&+match[1];
@@ -141,8 +141,6 @@ Benchmark.prototype._run = function() {
141141
// some options weren't set.
142142
// run with all combinations
143143
varmain=require.main.filename;
144-
varsettings=[];
145-
varqueueLen=1;
146144
varoptions=this.options;
147145

148146
varqueue=Object.keys(options).reduce(function(set,key){
@@ -210,7 +208,7 @@ function parseOpts(options) {
210208
});
211209
}
212210
returnnum===0 ? conf : null;
213-
};
211+
}
214212

215213
Benchmark.prototype.start=function(){
216214
if(this._started)
@@ -228,8 +226,8 @@ Benchmark.prototype.end = function(operations) {
228226
if(typeofoperations!=='number')
229227
thrownewError('called end() without specifying operation count');
230228

231-
vartime=elapsed[0]+elapsed[1]/1e9;
232-
varrate=operations/time;
229+
vartime=elapsed[0]+elapsed[1]/1e9;
230+
varrate=operations/time;
233231
this.report(rate);
234232
};
235233

‎benchmark/crypto/aes-gcm-throughput.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function AEAD_Bench(cipher, message, associate_data, key, iv, n, len) {
3131
varbob=crypto.createDecipheriv(cipher,key,iv);
3232
bob.setAuthTag(tag);
3333
bob.setAAD(associate_data);
34-
varclear=bob.update(enc);
34+
bob.update(enc);
3535
bob.final();
3636
}
3737

‎benchmark/crypto/cipher-stream.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ function legacyWrite(alice, bob, message, encoding, writes) {
9696
written+=dec.length;
9797
dec=bob.final();
9898
written+=dec.length;
99-
varbits=written*8;
10099
vargbits=written/(1024*1024*1024);
101100
bench.end(gbits);
102101
}

‎benchmark/crypto/hash-stream-creation.js‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ function main(conf) {
2121
api='legacy';
2222
}
2323

24-
varcrypto=require('crypto');
25-
varassert=require('assert');
26-
2724
varmessage;
2825
varencoding;
2926
switch(conf.type){

‎benchmark/crypto/hash-stream-throughput.js‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ function main(conf) {
2020
api='legacy';
2121
}
2222

23-
varcrypto=require('crypto');
24-
varassert=require('assert');
25-
2623
varmessage;
2724
varencoding;
2825
switch(conf.type){

‎benchmark/crypto/rsa-encrypt-decrypt-throughput.js‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ var bench = common.createBenchmark(main, {
2323
});
2424

2525
functionmain(conf){
26-
varcrypto=require('crypto');
2726
varmessage=(newBuffer(conf.len)).fill('b');
2827

2928
bench.start();
@@ -39,7 +38,7 @@ function StreamWrite(algo, keylen, message, n, len) {
3938
varpublicKey=RSA_PublicPem[keylen];
4039
for(vari=0;i<n;i++){
4140
varenc=crypto.privateEncrypt(privateKey,message);
42-
varclear=crypto.publicDecrypt(publicKey,enc);
41+
crypto.publicDecrypt(publicKey,enc);
4342
}
4443

4544
bench.end(kbits);

‎benchmark/crypto/rsa-sign-verify-throughput.js‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ var bench = common.createBenchmark(main, {
2424
});
2525

2626
functionmain(conf){
27-
varcrypto=require('crypto');
2827
varmessage=(newBuffer(conf.len)).fill('b');
2928

3029
bench.start();
@@ -37,7 +36,6 @@ function StreamWrite(algo, keylen, message, writes, len) {
3736
varkbits=bits/(1024);
3837

3938
varprivateKey=RSA_PrivatePem[keylen];
40-
varpublicKey=RSA_PublicPem[keylen];
4139
vars=crypto.createSign(algo);
4240
varv=crypto.createVerify(algo);
4341

@@ -46,7 +44,7 @@ function StreamWrite(algo, keylen, message, writes, len) {
4644
v.update(message);
4745
}
4846

49-
varsign=s.sign(privateKey,'binary');
47+
s.sign(privateKey,'binary');
5048
s.end();
5149
v.end();
5250

0 commit comments

Comments
 (0)