Skip to content

Commit efabc6a

Browse files
addaleaxjasnell
authored andcommitted
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 <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Brian White <[email protected]>
1 parent 3207ea4 commit efabc6a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

benchmark/fs/bench-readdir.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function main(conf) {
1414

1515
bench.start();
1616
(function r(cntr) {
17-
if (--cntr <= 0)
17+
if (cntr-- <= 0)
1818
return bench.end(n);
1919
fs.readdir(path.resolve(__dirname, '../../lib/'), function() {
2020
r(cntr);

benchmark/fs/bench-realpath.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function main(conf) {
2727

2828
function relativePath(n) {
2929
(function r(cntr) {
30-
if (--cntr <= 0)
30+
if (cntr-- <= 0)
3131
return bench.end(n);
3232
fs.realpath(relative_path, function() {
3333
r(cntr);
@@ -37,7 +37,7 @@ function relativePath(n) {
3737

3838
function resolvedPath(n) {
3939
(function r(cntr) {
40-
if (--cntr <= 0)
40+
if (cntr-- <= 0)
4141
return bench.end(n);
4242
fs.realpath(resolved_path, function() {
4343
r(cntr);

0 commit comments

Comments
 (0)