aboutsummaryrefslogtreecommitdiff
path: root/src/bench/bench.cpp
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2017-09-30 18:07:44 +0200
committerMarcoFalke <falke.marco@gmail.com>2017-09-30 18:07:55 +0200
commite542728cde676f218c552d841d0af29b92f9800b (patch)
tree992beca84e6a88affd99fa2caa9fed5747e5d40c /src/bench/bench.cpp
parent763231051596b8e3455b839911ad6a3a1f1c3c74 (diff)
parent1789e4675b17f274fcb0761321e6fd249a102f40 (diff)
downloadbitcoin-e542728cde676f218c552d841d0af29b92f9800b.tar.xz
Merge #11303: Fix estimatesmartfee rounding display issue
1789e4675 Force explicit double -> int conversion for CFeeRate constructor (Matt Corallo) 53a6590f4 Make float <-> int casts explicit outside of test, qt, CFeeRate (Matt Corallo) 0b1b9148c Remove countMaskInv caching in bench framework (Matt Corallo) Pull request description: This fixes an issue where estimatesmartfee which matches at the min relay fee will return 999 sat/byte instead of 1000 sat/byte due to a float rounding issue. I went ahead and made all float <-> int conversion outside of test/qt explicit (test only had one or two more, Qt had quite a few, including many in the Qt headers themselves) and added overloads to CFeeRate to force callers to do an explicit round themselves. Easy to test with -Wfloat-conversion. Tree-SHA512: 66087b08e5dfca67506da54ae057c2f9d86184415e8fa4fa0199e38839e06a3ce96c836fcb7593b7d960065f5240c594ff3a0cfa14333ac528421f5aeac835c9
Diffstat (limited to 'src/bench/bench.cpp')
-rw-r--r--src/bench/bench.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/bench/bench.cpp b/src/bench/bench.cpp
index 849d924af2..7b307d6f42 100644
--- a/src/bench/bench.cpp
+++ b/src/bench/bench.cpp
@@ -55,13 +55,13 @@ bool benchmark::State::KeepRunning()
else {
now = gettimedouble();
double elapsed = now - lastTime;
- double elapsedOne = elapsed * countMaskInv;
+ double elapsedOne = elapsed / (countMask + 1);
if (elapsedOne < minTime) minTime = elapsedOne;
if (elapsedOne > maxTime) maxTime = elapsedOne;
// We only use relative values, so don't have to handle 64-bit wrap-around specially
nowCycles = perf_cpucycles();
- uint64_t elapsedOneCycles = (nowCycles - lastCycles) * countMaskInv;
+ uint64_t elapsedOneCycles = (nowCycles - lastCycles) / (countMask + 1);
if (elapsedOneCycles < minCycles) minCycles = elapsedOneCycles;
if (elapsedOneCycles > maxCycles) maxCycles = elapsedOneCycles;
@@ -69,7 +69,6 @@ bool benchmark::State::KeepRunning()
// If the execution was much too fast (1/128th of maxElapsed), increase the count mask by 8x and restart timing.
// The restart avoids including the overhead of this code in the measurement.
countMask = ((countMask<<3)|7) & ((1LL<<60)-1);
- countMaskInv = 1./(countMask+1);
count = 0;
minTime = std::numeric_limits<double>::max();
maxTime = std::numeric_limits<double>::min();
@@ -81,7 +80,6 @@ bool benchmark::State::KeepRunning()
uint64_t newCountMask = ((countMask<<1)|1) & ((1LL<<60)-1);
if ((count & newCountMask)==0) {
countMask = newCountMask;
- countMaskInv = 1./(countMask+1);
}
}
}