Skip to content

Commit

Permalink
benchmark: (fs) use destructuring
Browse files Browse the repository at this point in the history
PR-URL: #18250
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
BridgeAR authored and evanlucas committed Jan 30, 2018
1 parent 4e19cbe commit 59271c8
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 33 deletions.
4 changes: 1 addition & 3 deletions benchmark/fs/bench-readdir.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ const bench = common.createBenchmark(main, {
});


function main(conf) {
const n = conf.n >>> 0;

function main({ n }) {
bench.start();
(function r(cntr) {
if (cntr-- <= 0)
Expand Down
4 changes: 1 addition & 3 deletions benchmark/fs/bench-readdirSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ const bench = common.createBenchmark(main, {
});


function main(conf) {
const n = conf.n >>> 0;

function main({ n }) {
bench.start();
for (var i = 0; i < n; i++) {
fs.readdirSync(path.resolve(__dirname, '../../lib/'));
Expand Down
5 changes: 1 addition & 4 deletions benchmark/fs/bench-realpath.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ const bench = common.createBenchmark(main, {
});


function main(conf) {
const n = conf.n >>> 0;
const pathType = conf.pathType;

function main({ n, pathType }) {
bench.start();
if (pathType === 'relative')
relativePath(n);
Expand Down
5 changes: 1 addition & 4 deletions benchmark/fs/bench-realpathSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ const bench = common.createBenchmark(main, {
});


function main(conf) {
const n = conf.n >>> 0;
const pathType = conf.pathType;

function main({ n, pathType }) {
bench.start();
if (pathType === 'relative')
relativePath(n);
Expand Down
4 changes: 1 addition & 3 deletions benchmark/fs/bench-stat.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ const bench = common.createBenchmark(main, {
});


function main(conf) {
const n = conf.n >>> 0;
const statType = conf.statType;
function main({ n, statType }) {
var arg;
if (statType === 'fstat')
arg = fs.openSync(__filename, 'r');
Expand Down
4 changes: 1 addition & 3 deletions benchmark/fs/bench-statSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ const bench = common.createBenchmark(main, {
});


function main(conf) {
const n = conf.n >>> 0;
const statSyncType = conf.statSyncType;
function main({ n, statSyncType }) {
const arg = (statSyncType === 'fstatSync' ?
fs.openSync(__filename, 'r') :
__dirname);
Expand Down
2 changes: 1 addition & 1 deletion benchmark/fs/read-stream-throughput.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const bench = common.createBenchmark(main, {

function main(conf) {
encodingType = conf.encodingType;
size = +conf.size;
size = conf.size;
filesize = conf.filesize;

switch (encodingType) {
Expand Down
4 changes: 1 addition & 3 deletions benchmark/fs/readFileSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ const bench = common.createBenchmark(main, {
n: [60e4]
});

function main(conf) {
const n = +conf.n;

function main({ n }) {
bench.start();
for (var i = 0; i < n; ++i)
fs.readFileSync(__filename);
Expand Down
8 changes: 3 additions & 5 deletions benchmark/fs/readfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ const bench = common.createBenchmark(main, {
concurrent: [1, 10]
});

function main(conf) {
const len = +conf.len;
function main({ len, dur, concurrent }) {
try { fs.unlinkSync(filename); } catch (e) {}
var data = Buffer.alloc(len, 'x');
fs.writeFileSync(filename, data);
Expand All @@ -30,7 +29,7 @@ function main(conf) {
bench.end(reads);
try { fs.unlinkSync(filename); } catch (e) {}
process.exit(0);
}, +conf.dur * 1000);
}, dur * 1000);

function read() {
fs.readFile(filename, afterRead);
Expand All @@ -48,6 +47,5 @@ function main(conf) {
read();
}

var cur = +conf.concurrent;
while (cur--) read();
while (concurrent--) read();
}
5 changes: 1 addition & 4 deletions benchmark/fs/write-stream-throughput.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ const bench = common.createBenchmark(main, {
size: [2, 1024, 65535, 1024 * 1024]
});

function main(conf) {
const dur = +conf.dur;
const encodingType = conf.encodingType;
const size = +conf.size;
function main({ dur, encodingType, size }) {
var encoding;

var chunk;
Expand Down

0 comments on commit 59271c8

Please sign in to comment.