diff --git a/src/Makefile.bench.include b/src/Makefile.bench.include --- a/src/Makefile.bench.include +++ b/src/Makefile.bench.include @@ -30,6 +30,7 @@ bench/gcs_filter.cpp \ bench/merkle_root.cpp \ bench/mempool_eviction.cpp \ + bench/rpc_blockchain.cpp \ bench/rpc_mempool.cpp \ bench/util_time.cpp \ bench/base58.cpp \ diff --git a/src/bench/CMakeLists.txt b/src/bench/CMakeLists.txt --- a/src/bench/CMakeLists.txt +++ b/src/bench/CMakeLists.txt @@ -53,6 +53,7 @@ merkle_root.cpp prevector.cpp rollingbloom.cpp + rpc_blockchain.cpp rpc_mempool.cpp util_time.cpp diff --git a/src/bench/rpc_blockchain.cpp b/src/bench/rpc_blockchain.cpp new file mode 100644 --- /dev/null +++ b/src/bench/rpc_blockchain.cpp @@ -0,0 +1,34 @@ +// Copyright (c) 2016-2019 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include +#include + +#include +#include +#include + +#include + +static void BlockToJsonVerbose(benchmark::State &state) { + CDataStream stream(benchmark::data::block413567, SER_NETWORK, + PROTOCOL_VERSION); + char a = '\0'; + // Prevent compaction + stream.write(&a, 1); + + CBlock block; + stream >> block; + + CBlockIndex blockindex; + const auto blockHash = block.GetHash(); + blockindex.phashBlock = &blockHash; + blockindex.nBits = 403014710; + + while (state.KeepRunning()) { + (void)blockToJSON(block, &blockindex, &blockindex, /*verbose*/ true); + } +} + +BENCHMARK(BlockToJsonVerbose, 10);