Skip to content

Instantly share code, notes, and snippets.

@jorangreef
Created September 25, 2018 15:27
Show Gist options
  • Save jorangreef/3eb9ee456cb484784bb094e11de9f7d1 to your computer and use it in GitHub Desktop.
Save jorangreef/3eb9ee456cb484784bb094e11de9f7d1 to your computer and use it in GitHub Desktop.
fs.fstat()
var fs = require('fs');
function callback(error) {
if (error) {
console.error(error);
process.exit(1);
return;
}
if (++count >= 1000000) {
console.log((Date.now() - now) + 'ms');
process.exit();
return;
}
fs.fstat(fd, callback);
}
var file = 'bench-fs-fstat';
fs.writeFileSync(file, '');
var fd = fs.openSync(file, 'r');
var now = Date.now();
var count = 0;
var concurrent = 32;
while (concurrent--) fs.fstat(fd, callback);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment