1'use strict'; 2 3const common = require('../common'); 4const fs = require('fs'); 5 6const bench = common.createBenchmark(main, { 7 n: [20e4], 8 statType: ['fstat', 'lstat', 'stat'] 9}); 10 11 12function main({ n, statType }) { 13 let arg; 14 if (statType === 'fstat') 15 arg = fs.openSync(__filename, 'r'); 16 else 17 arg = __filename; 18 19 bench.start(); 20 (function r(cntr, fn) { 21 if (cntr-- <= 0) { 22 bench.end(n); 23 if (statType === 'fstat') 24 fs.closeSync(arg); 25 return; 26 } 27 fn(arg, () => { 28 r(cntr, fn); 29 }); 30 }(n, fs[statType])); 31} 32