mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
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:
parent
a52878c239
commit
7e03ffcc12
@ -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)
|
||||
|
@ -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/'));
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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');
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user