-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
benchmark: add benches for fs.stat & fs.statSync #8338
Conversation
|
||
bench.start(); | ||
(function r(cntr) { | ||
if (--cntr <= 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: doesn't this make the benchmark run n - 1
times?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You’re right. I’ll fix this in the other tests, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lpinca done!
Fix a off-by-one error that made the benchmarks for asynchronous functions run `n - 1` times instead of `n` times.
Add very simple benchmarks for `fs.stat` and `fs.statSync` as well as `fs.lstat` and `fs.lstatSync` based on the `readdir` benchmarks.
bff12fa
to
82de541
Compare
LGTM |
LGTM. |
ping @mscdex |
fn(__filename, function() { | ||
r(cntr); | ||
}); | ||
}(n)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we should be passing fn
into the closure as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mscdex Done, if I understood you correctly.
|
||
function main(conf) { | ||
const n = conf.n >>> 0; | ||
const fn = fs[conf.kind]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how much it matters/affects things, but maybe we should change this variable name to avoid shadowing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ve simply replaced the only use of this variable with fs[conf.kind]
. It doesn’t seem to make any difference, and I would expect any difference it makes to be pretty weak in comparison to the cost of the actual syscall/thread pool operation.
LGTM |
Fix a off-by-one error that made the benchmarks for asynchronous functions run `n - 1` times instead of `n` times. PR-URL: #8338 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net>
Add very simple benchmarks for `fs.stat` and `fs.statSync` as well as `fs.lstat` and `fs.lstatSync` based on the `readdir` benchmarks. PR-URL: #8338 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net>
Landed in efabc6a and 450ee63 |
@jasnell Thanks for landing this! |
Fix a off-by-one error that made the benchmarks for asynchronous functions run `n - 1` times instead of `n` times. PR-URL: #8338 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net>
Add very simple benchmarks for `fs.stat` and `fs.statSync` as well as `fs.lstat` and `fs.lstatSync` based on the `readdir` benchmarks. PR-URL: #8338 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net>
This does not land cleanly in LTS. Added dont-land label. Please feel free to manually backport |
Add very simple benchmarks for `fs.stat` and `fs.statSync` as well as `fs.lstat` and `fs.lstatSync` based on the `readdir` benchmarks. PR-URL: #8338 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net>
Add very simple benchmarks for `fs.stat` and `fs.statSync` as well as `fs.lstat` and `fs.lstatSync` based on the `readdir` benchmarks. PR-URL: #8338 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net>
Add very simple benchmarks for `fs.stat` and `fs.statSync` as well as `fs.lstat` and `fs.lstatSync` based on the `readdir` benchmarks. PR-URL: #8338 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net>
Add very simple benchmarks for `fs.stat` and `fs.statSync` as well as `fs.lstat` and `fs.lstatSync` based on the `readdir` benchmarks. PR-URL: #8338 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net>
Checklist
make -j4 test
(UNIX), orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
benchmark
Description of change
Add very simple benchmarks for
fs.stat
andfs.statSync
as well asfs.lstat
andfs.lstatSync
based on thereaddir
benchmarks.Linter run: https://ci.nodejs.org/job/node-test-linter/4005/