Permalink
Browse files

fs: add initial set of fs.promises APIs

Initial set of fs.promises APIs with documentation and one
benchmark.

PR-URL: #18297
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
  • Loading branch information...
jasnell committed Jan 21, 2018
1 parent 85b37db commit 329fc78e4919231bf76771797878f7b0db0f73ac
@@ -0,0 +1,28 @@
'use strict';
const common = require('../common');
const fs = require('fs');
const bench = common.createBenchmark(main, {
n: [20e4],
statType: ['fstat', 'lstat', 'stat']
});
async function run(n, statType) {
const arg = statType === 'fstat' ?
await fs.promises.open(__filename, 'r') : __filename;
let remaining = n;
bench.start();
while (remaining-- > 0)
await fs.promises[statType](arg);
bench.end(n);
if (typeof arg.close === 'function')
await arg.close();
}
function main(conf) {
const n = conf.n >>> 0;
const statType = conf.statType;
run(n, statType).catch(console.log);
}
Oops, something went wrong.

0 comments on commit 329fc78

Please sign in to comment.