Bitcoin Core 28.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
readblock.cpp
Go to the documentation of this file.
1// Copyright (c) 2023 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
9#include <node/blockstorage.h>
10#include <streams.h>
12#include <util/chaintype.h>
13#include <validation.h>
14
16{
18 CBlock block;
19 stream >> TX_WITH_WITNESS(block);
20
21 return chainman.m_blockman.SaveBlockToDisk(block, 0);
22}
23
25{
27 ChainstateManager& chainman{*testing_setup->m_node.chainman};
28
29 CBlock block;
30 const auto pos{WriteBlockToDisk(chainman)};
31
32 bench.run([&] {
33 const auto success{chainman.m_blockman.ReadBlockFromDisk(block, pos)};
34 assert(success);
35 });
36}
37
39{
41 ChainstateManager& chainman{*testing_setup->m_node.chainman};
42
43 std::vector<uint8_t> block_data;
44 const auto pos{WriteBlockToDisk(chainman)};
45
46 bench.run([&] {
47 const auto success{chainman.m_blockman.ReadRawBlockFromDisk(block_data, pos)};
48 assert(success);
49 });
50}
51
#define BENCHMARK(n, priority_level)
Definition bench.h:79
Definition block.h:69
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
Definition validation.h:871
node::BlockManager m_blockman
A single BlockManager instance is shared across each constructed chainstate to avoid duplicating bloc...
Double ended buffer combining vector and stream-like interfaces.
Definition streams.h:147
Main entry point to nanobench's benchmarking facility.
Definition nanobench.h:627
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
Definition nanobench.h:1234
bool WriteUndoDataForBlock(const CBlockUndo &blockundo, BlockValidationState &state, CBlockIndex &block) EXCLUSIVE_LOCKS_REQUIRED(FlatFilePo SaveBlockToDisk)(const CBlock &block, int nHeight)
Store block on disk and update block file statistics.
const std::vector< uint8_t > block413567
Definition data.cpp:11
@ HIGH
Definition bench.h:47
static constexpr TransactionSerParams TX_WITH_WITNESS
static void ReadRawBlockFromDiskTest(benchmark::Bench &bench)
Definition readblock.cpp:38
static void ReadBlockFromDiskTest(benchmark::Bench &bench)
Definition readblock.cpp:24
static FlatFilePos WriteBlockToDisk(ChainstateManager &chainman)
Definition readblock.cpp:15
std::unique_ptr< T > MakeNoLogFileContext(const ChainType chain_type=ChainType::REGTEST, TestOpts opts={})
Make a test setup that has disk access to the debug.log file disabled.
assert(!tx.IsCoinBase())