0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/benchmark/fs/bench-statSync.js
Ruben Bridgewater 7e03ffcc12
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>
2018-01-23 01:29:29 +01:00

27 lines
503 B
JavaScript

'use strict';
const common = require('../common');
const fs = require('fs');
const bench = common.createBenchmark(main, {
n: [1e6],
statSyncType: ['fstatSync', 'lstatSync', 'statSync']
});
function main({ n, statSyncType }) {
const arg = (statSyncType === 'fstatSync' ?
fs.openSync(__filename, 'r') :
__dirname);
const fn = fs[statSyncType];
bench.start();
for (var i = 0; i < n; i++) {
fn(arg);
}
bench.end(n);
if (statSyncType === 'fstat')
fs.closeSync(arg);
}