Skip to content

Commit

Permalink
fs: add initial set of fs.promises APIs
Browse files Browse the repository at this point in the history
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 Feb 6, 2018
1 parent 85b37db commit 329fc78
Show file tree
Hide file tree
Showing 10 changed files with 1,957 additions and 187 deletions.
28 changes: 28 additions & 0 deletions benchmark/fs/bench-stat-promise.js
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit 329fc78

Please sign in to comment.