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%.

Github-Pull: #9200
Rebased-From: e0a9cb25b0
This commit is contained in:
Wladimir J. van der Laan 2016-11-22 09:59:50 +01:00 committed by Luke Dashjr
parent 0c09d9f00e
commit eebc699d30
1 changed files with 5 additions and 2 deletions

View File

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