Skip to content

Commit c4d16e8

Browse files
Trottaddaleax
authored andcommitted
benchmark: refactor for consistent style
Code in benchmark directory sometimes uses `function () {}` for anonymous callbacks and sometimes uses `() => {}`. Multi-line arrays sometimes have a trailing comma and sometimes do not. Update to always use arrow functions for anonymous callbacks and trailing commas for multiline arrays. PR-URL: #25944 Reviewed-By: Anto Aravinth <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 2d57504 commit c4d16e8

File tree

96 files changed

+158
-164
lines changed

Some content is hidden

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

96 files changed

+158
-164
lines changed

benchmark/_cli.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ const path = require('path');
66
// Create an object of all benchmark scripts
77
const benchmarks = {};
88
fs.readdirSync(__dirname)
9-
.filter(function(name) {
10-
return fs.statSync(path.resolve(__dirname, name)).isDirectory();
11-
})
12-
.forEach(function(category) {
9+
.filter((name) => fs.statSync(path.resolve(__dirname, name)).isDirectory())
10+
.forEach((category) => {
1311
benchmarks[category] = fs.readdirSync(path.resolve(__dirname, category))
1412
.filter((filename) => filename[0] !== '.' && filename[0] !== '_');
1513
});

benchmark/buffers/buffer-bytelength.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const chars = [
1212
'hello brendan!!!', // 1 byte
1313
'ΰαβγδεζηθικλμνξο', // 2 bytes
1414
'挰挱挲挳挴挵挶挷挸挹挺挻挼挽挾挿', // 3 bytes
15-
'𠜎𠜱𠝹𠱓𠱸𠲖𠳏𠳕𠴕𠵼𠵿𠸎𠸏𠹷𠺝𠺢' // 4 bytes
15+
'𠜎𠜱𠝹𠱓𠱸𠲖𠳏𠳕𠴕𠵼𠵿𠸎𠸏𠹷𠺝𠺢', // 4 bytes
1616
];
1717

1818
function main({ n, len, encoding }) {
@@ -33,9 +33,7 @@ function main({ n, len, encoding }) {
3333
}
3434

3535
// Check the result to ensure it is *properly* optimized
36-
results = strings.map(function(val) {
37-
return Buffer.byteLength(val, encoding);
38-
});
36+
results = strings.map((val) => Buffer.byteLength(val, encoding));
3937
}
4038

4139
bench.start();

benchmark/buffers/buffer-fill.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const bench = common.createBenchmark(main, {
1212
'fill("t", "utf8")',
1313
'fill("t", 0, "utf8")',
1414
'fill("t", 0)',
15-
'fill(Buffer.alloc(1), 0)'
15+
'fill(Buffer.alloc(1), 0)',
1616
],
1717
size: [2 ** 8, 2 ** 13, 2 ** 16],
1818
n: [2e4]

benchmark/buffers/buffer-from.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const bench = common.createBenchmark(main, {
1212
'string',
1313
'string-utf8',
1414
'string-base64',
15-
'object'
15+
'object',
1616
],
1717
len: [10, 2048],
1818
n: [2048]

benchmark/buffers/buffer-indexof.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const searchStrings = [
1818
'Soo--oop',
1919
'aaaaaaaaaaaaaaaaa',
2020
'venture to go near the house till she had brought herself down to',
21-
'</i> to the Caterpillar'
21+
'</i> to the Caterpillar',
2222
];
2323

2424
const bench = common.createBenchmark(main, {

benchmark/buffers/buffer-normalize-encoding.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const bench = common.createBenchmark(main, {
2525
'utf16le',
2626
'UTF16LE',
2727
'utf8',
28-
'UTF8'
28+
'UTF8',
2929
],
3030
n: [1e6]
3131
}, {

benchmark/buffers/buffer-read-with-byteLength.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const types = [
55
'IntBE',
66
'IntLE',
77
'UIntBE',
8-
'UIntLE'
8+
'UIntLE',
99
];
1010

1111
const bench = common.createBenchmark(main, {

benchmark/buffers/buffer-read.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const types = [
1515
'FloatLE',
1616
'FloatBE',
1717
'DoubleLE',
18-
'DoubleBE'
18+
'DoubleBE',
1919
];
2020

2121
const bench = common.createBenchmark(main, {

benchmark/buffers/buffer-write-string.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const common = require('../common.js');
44
const bench = common.createBenchmark(main, {
55
encoding: [
6-
'', 'utf8', 'ascii', 'hex', 'UCS-2', 'utf16le', 'latin1', 'binary'
6+
'', 'utf8', 'ascii', 'hex', 'UCS-2', 'utf16le', 'latin1', 'binary',
77
],
88
args: [ '', 'offset', 'offset+length' ],
99
len: [10, 2048],

benchmark/buffers/buffer-write.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const types = [
1919
'FloatLE',
2020
'FloatBE',
2121
'DoubleLE',
22-
'DoubleBE'
22+
'DoubleBE',
2323
];
2424

2525
const bench = common.createBenchmark(main, {

0 commit comments

Comments
 (0)