2020-04-16 13:14:08 -04:00
|
|
|
// Copyright (c) 2016-2020 The Bitcoin Core developers
|
2019-06-22 13:37:51 +03:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
#include <bench/bench.h>
|
|
|
|
#include <bench/data.h>
|
|
|
|
|
|
|
|
#include <rpc/blockchain.h>
|
2020-04-16 13:11:54 -04:00
|
|
|
#include <streams.h>
|
|
|
|
#include <validation.h>
|
2019-06-22 13:37:51 +03:00
|
|
|
|
|
|
|
#include <univalue.h>
|
|
|
|
|
|
|
|
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);
|