From 91509ffe247b0eacbf84214c7c9c3f8a0012f2eb Mon Sep 17 00:00:00 2001 From: Kirill Fomichev Date: Sat, 22 Jun 2019 13:37:51 +0300 Subject: bench: Benchmark blockToJSON --- src/bench/rpc_blockchain.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/bench/rpc_blockchain.cpp (limited to 'src/bench/rpc_blockchain.cpp') diff --git a/src/bench/rpc_blockchain.cpp b/src/bench/rpc_blockchain.cpp new file mode 100644 index 0000000000..29e448fc43 --- /dev/null +++ b/src/bench/rpc_blockchain.cpp @@ -0,0 +1,33 @@ +// 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 + +#include + +static void BlockToJsonVerbose(benchmark::State& state) { + CDataStream stream(benchmark::data::block413567, SER_NETWORK, PROTOCOL_VERSION); + char a = '\0'; + stream.write(&a, 1); // Prevent compaction + + CBlock block; + stream >> block; + + CBlockIndex blockindex; + const uint256 blockHash = block.GetHash(); + blockindex.phashBlock = &blockHash; + blockindex.nBits = 403014710; + + while (state.KeepRunning()) { + (void)blockToJSON(block, &blockindex, &blockindex, /*verbose*/ true); + } +} + +BENCHMARK(BlockToJsonVerbose, 10); -- cgit v1.2.3