mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-19 05:45:05 +01:00
bench: Benchmark blockToJSON
This commit is contained in:
parent
4f378ac30c
commit
91509ffe24
@ -24,6 +24,7 @@
|
|||||||
<ClCompile Include="..\..\src\bench\examples.cpp" />
|
<ClCompile Include="..\..\src\bench\examples.cpp" />
|
||||||
<ClCompile Include="..\..\src\bench\lockedpool.cpp" />
|
<ClCompile Include="..\..\src\bench\lockedpool.cpp" />
|
||||||
<ClCompile Include="..\..\src\bench\mempool_eviction.cpp" />
|
<ClCompile Include="..\..\src\bench\mempool_eviction.cpp" />
|
||||||
|
<ClCompile Include="..\..\src\bench\rpc_blockchain.cpp" />
|
||||||
<ClCompile Include="..\..\src\bench\rpc_mempool.cpp" />
|
<ClCompile Include="..\..\src\bench\rpc_mempool.cpp" />
|
||||||
<ClCompile Include="..\..\src\bench\merkle_root.cpp" />
|
<ClCompile Include="..\..\src\bench\merkle_root.cpp" />
|
||||||
<ClCompile Include="..\..\src\bench\rollingbloom.cpp" />
|
<ClCompile Include="..\..\src\bench\rollingbloom.cpp" />
|
||||||
|
@ -29,6 +29,7 @@ bench_bench_bitcoin_SOURCES = \
|
|||||||
bench/gcs_filter.cpp \
|
bench/gcs_filter.cpp \
|
||||||
bench/merkle_root.cpp \
|
bench/merkle_root.cpp \
|
||||||
bench/mempool_eviction.cpp \
|
bench/mempool_eviction.cpp \
|
||||||
|
bench/rpc_blockchain.cpp \
|
||||||
bench/rpc_mempool.cpp \
|
bench/rpc_mempool.cpp \
|
||||||
bench/util_time.cpp \
|
bench/util_time.cpp \
|
||||||
bench/verify_script.cpp \
|
bench/verify_script.cpp \
|
||||||
|
33
src/bench/rpc_blockchain.cpp
Normal file
33
src/bench/rpc_blockchain.cpp
Normal file
@ -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 <bench/bench.h>
|
||||||
|
#include <bench/data.h>
|
||||||
|
|
||||||
|
#include <validation.h>
|
||||||
|
#include <streams.h>
|
||||||
|
#include <consensus/validation.h>
|
||||||
|
#include <rpc/blockchain.h>
|
||||||
|
|
||||||
|
#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);
|
Loading…
Reference in New Issue
Block a user