2016-08-30 12:52:41 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common');
|
|
|
|
const fs = require('fs');
|
|
|
|
|
|
|
|
const bench = common.createBenchmark(main, {
|
2017-03-12 00:41:20 +00:00
|
|
|
n: [20e4],
|
|
|
|
kind: ['fstat', 'lstat', 'stat']
|
2016-08-30 12:52:41 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
function main(conf) {
|
|
|
|
const n = conf.n >>> 0;
|
2017-03-12 00:41:20 +00:00
|
|
|
const kind = conf.kind;
|
|
|
|
var arg;
|
|
|
|
if (kind === 'fstat')
|
|
|
|
arg = fs.openSync(__filename, 'r');
|
|
|
|
else
|
|
|
|
arg = __filename;
|
2016-08-30 12:52:41 +00:00
|
|
|
|
|
|
|
bench.start();
|
|
|
|
(function r(cntr, fn) {
|
2017-03-12 00:41:20 +00:00
|
|
|
if (cntr-- <= 0) {
|
|
|
|
bench.end(n);
|
|
|
|
if (kind === 'fstat')
|
|
|
|
fs.closeSync(arg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
fn(arg, function() {
|
2016-08-30 12:52:41 +00:00
|
|
|
r(cntr, fn);
|
|
|
|
});
|
2017-03-12 00:41:20 +00:00
|
|
|
}(n, fs[kind]));
|
2016-08-30 12:52:41 +00:00
|
|
|
}
|