Permalink
Browse files

benchmark: fix off-by-one error in fs benchmarks

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 Fishrock123 committed Aug 30, 2016
1 parent 3ce6eaa commit 7cc13912876dfebf7d84e450c908ce6af1d826d0
Showing with 3 additions and 3 deletions.
  1. +1 −1 benchmark/fs/bench-readdir.js
  2. +2 −2 benchmark/fs/bench-realpath.js
@@ -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);
@@ -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);
@@ -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);

0 comments on commit 7cc1391

Please sign in to comment.