Skip to content

Commit 59271c8

Browse files
BridgeARevanlucas
authored andcommitted
benchmark: (fs) use destructuring
PR-URL: #18250 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 4e19cbe commit 59271c8

10 files changed

+12
-33
lines changed

benchmark/fs/bench-readdir.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ const bench = common.createBenchmark(main, {
99
});
1010

1111

12-
function main(conf) {
13-
const n = conf.n >>> 0;
14-
12+
function main({ n }) {
1513
bench.start();
1614
(function r(cntr) {
1715
if (cntr-- <= 0)

benchmark/fs/bench-readdirSync.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ const bench = common.createBenchmark(main, {
99
});
1010

1111

12-
function main(conf) {
13-
const n = conf.n >>> 0;
14-
12+
function main({ n }) {
1513
bench.start();
1614
for (var i = 0; i < n; i++) {
1715
fs.readdirSync(path.resolve(__dirname, '../../lib/'));

benchmark/fs/bench-realpath.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ const bench = common.createBenchmark(main, {
1212
});
1313

1414

15-
function main(conf) {
16-
const n = conf.n >>> 0;
17-
const pathType = conf.pathType;
18-
15+
function main({ n, pathType }) {
1916
bench.start();
2017
if (pathType === 'relative')
2118
relativePath(n);

benchmark/fs/bench-realpathSync.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ const bench = common.createBenchmark(main, {
1414
});
1515

1616

17-
function main(conf) {
18-
const n = conf.n >>> 0;
19-
const pathType = conf.pathType;
20-
17+
function main({ n, pathType }) {
2118
bench.start();
2219
if (pathType === 'relative')
2320
relativePath(n);

benchmark/fs/bench-stat.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ const bench = common.createBenchmark(main, {
99
});
1010

1111

12-
function main(conf) {
13-
const n = conf.n >>> 0;
14-
const statType = conf.statType;
12+
function main({ n, statType }) {
1513
var arg;
1614
if (statType === 'fstat')
1715
arg = fs.openSync(__filename, 'r');

benchmark/fs/bench-statSync.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ const bench = common.createBenchmark(main, {
99
});
1010

1111

12-
function main(conf) {
13-
const n = conf.n >>> 0;
14-
const statSyncType = conf.statSyncType;
12+
function main({ n, statSyncType }) {
1513
const arg = (statSyncType === 'fstatSync' ?
1614
fs.openSync(__filename, 'r') :
1715
__dirname);

benchmark/fs/read-stream-throughput.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const bench = common.createBenchmark(main, {
1818

1919
function main(conf) {
2020
encodingType = conf.encodingType;
21-
size = +conf.size;
21+
size = conf.size;
2222
filesize = conf.filesize;
2323

2424
switch (encodingType) {

benchmark/fs/readFileSync.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ const bench = common.createBenchmark(main, {
77
n: [60e4]
88
});
99

10-
function main(conf) {
11-
const n = +conf.n;
12-
10+
function main({ n }) {
1311
bench.start();
1412
for (var i = 0; i < n; ++i)
1513
fs.readFileSync(__filename);

benchmark/fs/readfile.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ const bench = common.createBenchmark(main, {
1515
concurrent: [1, 10]
1616
});
1717

18-
function main(conf) {
19-
const len = +conf.len;
18+
function main({ len, dur, concurrent }) {
2019
try { fs.unlinkSync(filename); } catch (e) {}
2120
var data = Buffer.alloc(len, 'x');
2221
fs.writeFileSync(filename, data);
@@ -30,7 +29,7 @@ function main(conf) {
3029
bench.end(reads);
3130
try { fs.unlinkSync(filename); } catch (e) {}
3231
process.exit(0);
33-
}, +conf.dur * 1000);
32+
}, dur * 1000);
3433

3534
function read() {
3635
fs.readFile(filename, afterRead);
@@ -48,6 +47,5 @@ function main(conf) {
4847
read();
4948
}
5049

51-
var cur = +conf.concurrent;
52-
while (cur--) read();
50+
while (concurrent--) read();
5351
}

benchmark/fs/write-stream-throughput.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ const bench = common.createBenchmark(main, {
1313
size: [2, 1024, 65535, 1024 * 1024]
1414
});
1515

16-
function main(conf) {
17-
const dur = +conf.dur;
18-
const encodingType = conf.encodingType;
19-
const size = +conf.size;
16+
function main({ dur, encodingType, size }) {
2017
var encoding;
2118

2219
var chunk;

0 commit comments

Comments
 (0)