Skip to content

Commit

Permalink
benchmark: fix off-by-one error in fs benchmarks
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
addaleax authored and jasnell committed Sep 12, 2016
1 parent 3207ea4 commit efabc6a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion benchmark/fs/bench-readdir.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function main(conf) {

bench.start();
(function r(cntr) {
if (--cntr <= 0)
if (cntr-- <= 0)
return bench.end(n);
fs.readdir(path.resolve(__dirname, '../../lib/'), function() {
r(cntr);
Expand Down
4 changes: 2 additions & 2 deletions benchmark/fs/bench-realpath.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function main(conf) {

function relativePath(n) {
(function r(cntr) {
if (--cntr <= 0)
if (cntr-- <= 0)
return bench.end(n);
fs.realpath(relative_path, function() {
r(cntr);
Expand All @@ -37,7 +37,7 @@ function relativePath(n) {

function resolvedPath(n) {
(function r(cntr) {
if (--cntr <= 0)
if (cntr-- <= 0)
return bench.end(n);
fs.realpath(resolved_path, function() {
r(cntr);
Expand Down

0 comments on commit efabc6a

Please sign in to comment.