From e4281a84bc61e59fb2bb5008ffbe34c3d607677c Mon Sep 17 00:00:00 2001 From: Michel van Kessel Date: Thu, 17 Dec 2020 14:21:06 +0100 Subject: [PATCH] beautify bench --- src/bench/.gitignore | 3 ++- src/bench/Examples.cpp | 6 +++--- src/bench/base58.cpp | 6 +++--- src/bench/bench.cpp | 11 ++++------- src/bench/bench_bitcoin.cpp | 8 ++++---- src/bench/cashaddr.cpp | 6 +++--- src/bench/ccoins_caching.cpp | 8 ++++---- src/bench/coin_selection.cpp | 7 +++---- src/bench/crypto_hash.cpp | 18 +++++++++--------- src/bench/mempool_eviction.cpp | 6 +++--- src/bench/rollingbloom.cpp | 6 +++--- 11 files changed, 41 insertions(+), 44 deletions(-) diff --git a/src/bench/.gitignore b/src/bench/.gitignore index e231fe4ca..32c037022 100644 --- a/src/bench/.gitignore +++ b/src/bench/.gitignore @@ -1 +1,2 @@ -bench_bitcoin +bench_blackmore +bench_bitcoin \ No newline at end of file diff --git a/src/bench/Examples.cpp b/src/bench/Examples.cpp index b6b020a97..e6e27d4f5 100644 --- a/src/bench/Examples.cpp +++ b/src/bench/Examples.cpp @@ -2,9 +2,9 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include "bench.h" -#include "main.h" -#include "utiltime.h" +#include +#include +#include // Sanity test: this should loop ten times, and // min/max/average should be close to 100ms. diff --git a/src/bench/base58.cpp b/src/bench/base58.cpp index 1279c3e7d..14c59186a 100644 --- a/src/bench/base58.cpp +++ b/src/bench/base58.cpp @@ -2,10 +2,10 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include "bench.h" +#include -#include "main.h" -#include "base58.h" +#include +#include #include #include diff --git a/src/bench/bench.cpp b/src/bench/bench.cpp index 8942da8c7..6b229f5f9 100644 --- a/src/bench/bench.cpp +++ b/src/bench/bench.cpp @@ -2,7 +2,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include "bench.h" +#include #include #include @@ -14,7 +14,7 @@ std::map BenchRunner::benchmarks; static double gettimedouble(void) { struct timeval tv; - gettimeofday(&tv, NULL); + gettimeofday(&tv, nullptr); return tv.tv_usec * 0.000001 + tv.tv_sec; } @@ -64,11 +64,8 @@ bool State::KeepRunning() return true; } if (elapsed*16 < maxElapsed) { - uint64_t newCountMask = ((countMask<<1)|1) & ((1LL<<60)-1); - if ((count & newCountMask)==0) { - countMask = newCountMask; - countMaskInv = 1./(countMask+1); - } + countMask = ((countMask<<1)|1) & ((1LL<<60)-1); + countMaskInv = 1./(countMask+1); } } lastTime = now; diff --git a/src/bench/bench_bitcoin.cpp b/src/bench/bench_bitcoin.cpp index db1402216..ce4eca0e5 100644 --- a/src/bench/bench_bitcoin.cpp +++ b/src/bench/bench_bitcoin.cpp @@ -2,11 +2,11 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include "bench.h" +#include -#include "key.h" -#include "main.h" -#include "util.h" +#include +#include +#include int main(int argc, char** argv) diff --git a/src/bench/cashaddr.cpp b/src/bench/cashaddr.cpp index fa2721de1..b8eff6a65 100644 --- a/src/bench/cashaddr.cpp +++ b/src/bench/cashaddr.cpp @@ -2,8 +2,8 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include "cashaddr.h" -#include "bench.h" +#include +#include #include #include @@ -29,4 +29,4 @@ static void CashAddrDecode(benchmark::State &state) { } BENCHMARK(CashAddrEncode); -BENCHMARK(CashAddrDecode); \ No newline at end of file +BENCHMARK(CashAddrDecode); diff --git a/src/bench/ccoins_caching.cpp b/src/bench/ccoins_caching.cpp index 1e8e3d462..3017db104 100644 --- a/src/bench/ccoins_caching.cpp +++ b/src/bench/ccoins_caching.cpp @@ -2,10 +2,10 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include "bench.h" -#include "coins.h" -#include "policy/policy.h" -#include "wallet/crypter.h" +#include +#include +#include +#include #include diff --git a/src/bench/coin_selection.cpp b/src/bench/coin_selection.cpp index ce1ce511e..f01ac6f6f 100644 --- a/src/bench/coin_selection.cpp +++ b/src/bench/coin_selection.cpp @@ -2,10 +2,9 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include "bench.h" -#include "wallet/wallet.h" +#include +#include -#include #include using namespace std; @@ -41,7 +40,7 @@ static void CoinSelection(benchmark::State& state) while (state.KeepRunning()) { // Empty wallet. - BOOST_FOREACH (COutput output, vCoins) + for(COutput output: vCoins) delete output.tx; vCoins.clear(); diff --git a/src/bench/crypto_hash.cpp b/src/bench/crypto_hash.cpp index 168006154..879b295ed 100644 --- a/src/bench/crypto_hash.cpp +++ b/src/bench/crypto_hash.cpp @@ -4,15 +4,15 @@ #include -#include "bench.h" -#include "bloom.h" -#include "hash.h" -#include "uint256.h" -#include "utiltime.h" -#include "crypto/ripemd160.h" -#include "crypto/sha1.h" -#include "crypto/sha256.h" -#include "crypto/sha512.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include /* Number of bytes to hash per iteration */ static const uint64_t BUFFER_SIZE = 1000*1000; diff --git a/src/bench/mempool_eviction.cpp b/src/bench/mempool_eviction.cpp index eaf7dfe8f..f5dff774c 100644 --- a/src/bench/mempool_eviction.cpp +++ b/src/bench/mempool_eviction.cpp @@ -2,9 +2,9 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include "bench.h" -#include "policy/policy.h" -#include "txmempool.h" +#include +#include +#include #include #include diff --git a/src/bench/rollingbloom.cpp b/src/bench/rollingbloom.cpp index 73c02cf71..d9d1b5f17 100644 --- a/src/bench/rollingbloom.cpp +++ b/src/bench/rollingbloom.cpp @@ -4,9 +4,9 @@ #include -#include "bench.h" -#include "bloom.h" -#include "utiltime.h" +#include +#include +#include static void RollingBloom(benchmark::State& state) {