benchmark: (fs) use destructuring

PR-URL: https://github.com/nodejs/node/pull/18250
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Ruben Bridgewater 2017-12-30 03:57:52 +01:00
parent a52878c239
commit 7e03ffcc12
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762
10 changed files with 12 additions and 33 deletions

View File

@ -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)

View File

@ -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/'));

View File

@ -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);

View File

@ -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);

View File

@ -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');

View File

@ -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);

View File

@ -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) {

View File

@ -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);

View File

@ -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);
@ -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);
@ -48,6 +47,5 @@ function main(conf) {
read();
}
var cur = +conf.concurrent;
while (cur--) read();
while (concurrent--) read();
}

View File

@ -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;