diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-11-22 09:59:50 +0100 |
---|---|---|
committer | Luke Dashjr <luke-jr+git@utopios.org> | 2016-12-02 07:52:12 +0000 |
commit | eebc699d3070c71365a0f3542e2f5f6eca3fd281 (patch) | |
tree | 764401e6520a6354da0a97c977eb05df67e95b81 /src/bench | |
parent | 0c09d9f00e39c4b1aee0fcb091fba068845b8edd (diff) | |
download | bitcoin-eebc699d3070c71365a0f3542e2f5f6eca3fd281.tar.xz |
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: e0a9cb25b0af87723d50cb8d8cffa10f1ebf7dcc
Diffstat (limited to 'src/bench')
-rw-r--r-- | src/bench/bench.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/bench/bench.cpp b/src/bench/bench.cpp index 227546a7a7..8942da8c74 100644 --- a/src/bench/bench.cpp +++ b/src/bench/bench.cpp @@ -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; |