Browse Source

bench: Fix subtle counting issue when rescaling iteration count

Make sure that the count is a zero modulo the new mask before
scaling, otherwise the next time until a measure triggers
will take only 1/2 as long as accounted for. This caused
the 'min time' to be potentially off by as much as 100%.
0.14
Wladimir J. van der Laan 8 years ago
parent
commit
e0a9cb25b0
  1. 5
      src/bench/bench.cpp

5
src/bench/bench.cpp

@ -64,10 +64,13 @@ bool State::KeepRunning() @@ -64,10 +64,13 @@ bool State::KeepRunning()
return true;
}
if (elapsed*16 < maxElapsed) {
countMask = ((countMask<<1)|1) & ((1LL<<60)-1);
uint64_t newCountMask = ((countMask<<1)|1) & ((1LL<<60)-1);
if ((count & newCountMask)==0) {
countMask = newCountMask;
countMaskInv = 1./(countMask+1);
}
}
}
lastTime = now;
++count;

Loading…
Cancel
Save