1 // Copyright (c) 2016-2020 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #include <bench/bench.h>
6 #include <bench/data.h>
7 
8 #include <rpc/blockchain.h>
9 #include <streams.h>
10 #include <validation.h>
11 
12 #include <univalue.h>
13 
BlockToJsonVerbose(benchmark::Bench & bench)14 static void BlockToJsonVerbose(benchmark::Bench& bench)
15 {
16     CDataStream stream(benchmark::data::block413567, SER_NETWORK, PROTOCOL_VERSION);
17     char a = '\0';
18     stream.write(&a, 1); // Prevent compaction
19 
20     CBlock block;
21     stream >> block;
22 
23     CBlockIndex blockindex;
24     const uint256 blockHash = block.GetHash();
25     blockindex.phashBlock = &blockHash;
26     blockindex.nBits = 403014710;
27 
28     bench.run([&] {
29         (void)blockToJSON(block, &blockindex, &blockindex, /*verbose*/ true);
30     });
31 }
32 
33 BENCHMARK(BlockToJsonVerbose);
34