Browse Source

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: https://github.com/nodejs/node/pull/8338
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
v7.x
Anna Henningsen 8 years ago
committed by James M Snell
parent
commit
efabc6ae4d
  1. 2
      benchmark/fs/bench-readdir.js
  2. 4
      benchmark/fs/bench-realpath.js

2
benchmark/fs/bench-readdir.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);

4
benchmark/fs/bench-realpath.js

@ -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);

Loading…
Cancel
Save