Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit dcfda10

Browse filesBrowse 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
Copy full SHA for dcfda10

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

49 files changed

+118
-160
lines changed
Open diff view settings
Collapse file

‎benchmark/buffers/buffer-bytelength.js‎

Copy file name to clipboardExpand all lines: benchmark/buffers/buffer-bytelength.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function main(conf) {
4444
var r = Buffer.byteLength(strings[index], encoding);
4545

4646
if (r !== results[index])
47-
throw Error('incorrect return value');
47+
throw new Error('incorrect return value');
4848
}
4949
bench.end(n);
5050
}
Collapse file

‎benchmark/buffers/buffer-read.js‎

Copy file name to clipboardExpand all lines: benchmark/buffers/buffer-read.js
+4-4Lines 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
var testFunction = new Function('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);
Collapse file

‎benchmark/buffers/buffer-write.js‎

Copy file name to clipboardExpand all lines: benchmark/buffers/buffer-write.js
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,21 @@ function main(conf) {
4848
function benchInt(buff, fn, len, noAssert) {
4949
var m = mod[fn];
5050
var testFunction = new Function('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
function benchFloat(buff, fn, len, noAssert) {
6161
var testFunction = new Function('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);
Collapse file

‎benchmark/common.js‎

Copy file name to clipboardExpand all lines: benchmark/common.js
+7-9Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ if (module === require.main) {
2828
var tests = fs.readdirSync(dir);
2929

3030
if (testFilter) {
31-
var filteredTests = tests.filter(function(item){
31+
var filteredTests = tests.filter(function(item) {
3232
if (item.lastIndexOf(testFilter) >= 0) {
3333
return item;
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
var self = 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
var match = out.match(regexp);
127127
var qps = match && +match[1];
@@ -141,8 +141,6 @@ Benchmark.prototype._run = function() {
141141
// some options weren't set.
142142
// run with all combinations
143143
var main = require.main.filename;
144-
var settings = [];
145-
var queueLen = 1;
146144
var options = this.options;
147145

148146
var queue = Object.keys(options).reduce(function(set, key) {
@@ -210,7 +208,7 @@ function parseOpts(options) {
210208
});
211209
}
212210
return num === 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 (typeof operations !== 'number')
229227
throw new Error('called end() without specifying operation count');
230228

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

Collapse file

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

Copy file name to clipboardExpand all lines: benchmark/crypto/aes-gcm-throughput.js
+1-1Lines 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
var bob = crypto.createDecipheriv(cipher, key, iv);
3232
bob.setAuthTag(tag);
3333
bob.setAAD(associate_data);
34-
var clear = bob.update(enc);
34+
bob.update(enc);
3535
bob.final();
3636
}
3737

Collapse file

‎benchmark/crypto/cipher-stream.js‎

Copy file name to clipboardExpand all lines: benchmark/crypto/cipher-stream.js
-1Lines 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-
var bits = written * 8;
10099
var gbits = written / (1024 * 1024 * 1024);
101100
bench.end(gbits);
102101
}
Collapse file

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

Copy file name to clipboardExpand all lines: benchmark/crypto/hash-stream-creation.js
-3Lines 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-
var crypto = require('crypto');
25-
var assert = require('assert');
26-
2724
var message;
2825
var encoding;
2926
switch (conf.type) {
Collapse file

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

Copy file name to clipboardExpand all lines: benchmark/crypto/hash-stream-throughput.js
-3Lines 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-
var crypto = require('crypto');
24-
var assert = require('assert');
25-
2623
var message;
2724
var encoding;
2825
switch (conf.type) {
Collapse file

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

Copy file name to clipboardExpand all lines: benchmark/crypto/rsa-encrypt-decrypt-throughput.js
+1-2Lines 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
function main(conf) {
26-
var crypto = require('crypto');
2726
var message = (new Buffer(conf.len)).fill('b');
2827

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

4544
bench.end(kbits);
Collapse file

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

Copy file name to clipboardExpand all lines: benchmark/crypto/rsa-sign-verify-throughput.js
+1-3Lines 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
function main(conf) {
27-
var crypto = require('crypto');
2827
var message = (new Buffer(conf.len)).fill('b');
2928

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

3938
var privateKey = RSA_PrivatePem[keylen];
40-
var publicKey = RSA_PublicPem[keylen];
4139
var s = crypto.createSign(algo);
4240
var v = crypto.createVerify(algo);
4341

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

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.