Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs: add promises API #18297

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could just be 2e5?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. There are a couple like this in the benchmark suite. I'll update those all separately.

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);
}
Loading