bench: measure CheckBlock speed separately from serialization

> cmake -B build -DBUILD_BENCH=ON -DCMAKE_BUILD_TYPE=Release && cmake --build build -j$(nproc) && build/src/bench/bench_bitcoin -filter='CheckBlockBench|DuplicateInputs' -min-time=10000

> C++ compiler .......................... AppleClang 16.0.0.16000026

|            ns/block |             block/s |    err% |     total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
|          372,743.63 |            2,682.81 |    1.1% |     10.99 | `CheckBlockBench`

|               ns/op |                op/s |    err% |     total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
|        3,304,694.54 |              302.60 |    0.5% |     11.05 | `DuplicateInputs`

> C++ compiler .......................... GNU 13.3.0

|            ns/block |             block/s |    err% |       ins/block |       cyc/block |    IPC |      bra/block |   miss% |     total | benchmark
|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
|        1,096,261.84 |              912.19 |    0.1% |    7,963,390.88 |    3,487,375.26 |  2.283 |   1,266,941.00 |    1.8% |     11.03 | `CheckBlockBench`

|               ns/op |                op/s |    err% |          ins/op |          cyc/op |    IPC |         bra/op |   miss% |     total | benchmark
|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
|        8,366,309.48 |              119.53 |    0.0% |   23,865,177.67 |   26,620,160.23 |  0.897 |   5,972,887.41 |    4.0% |     10.78 | `DuplicateInputs`
This commit is contained in:
Lőrinc 2025-01-18 11:43:26 +01:00
parent c15d130752
commit bf580d7b4e

View file

@ -21,7 +21,7 @@
#include <optional>
#include <vector>
static void SizeComputerBlock(benchmark::Bench& bench) {
static void SizeComputerBlockBench(benchmark::Bench& bench) {
CBlock block;
DataStream(benchmark::data::block413567) >> TX_WITH_WITNESS(block);
@ -32,7 +32,7 @@ static void SizeComputerBlock(benchmark::Bench& bench) {
});
}
static void SerializeBlock(benchmark::Bench& bench) {
static void SerializeBlockBench(benchmark::Bench& bench) {
CBlock block;
DataStream(benchmark::data::block413567) >> TX_WITH_WITNESS(block);
@ -48,7 +48,7 @@ static void SerializeBlock(benchmark::Bench& bench) {
// a block off the wire, but before we can relay the block on to peers using
// compact block relay.
static void DeserializeBlock(benchmark::Bench& bench)
static void DeserializeBlockBench(benchmark::Bench& bench)
{
DataStream stream(benchmark::data::block413567);
std::byte a{0};
@ -83,7 +83,7 @@ static void DeserializeAndCheckBlock(benchmark::Bench& bench)
});
}
BENCHMARK(SizeComputerBlock, benchmark::PriorityLevel::HIGH);
BENCHMARK(SerializeBlock, benchmark::PriorityLevel::HIGH);
BENCHMARK(DeserializeBlock, benchmark::PriorityLevel::HIGH);
BENCHMARK(SizeComputerBlockBench, benchmark::PriorityLevel::HIGH);
BENCHMARK(SerializeBlockBench, benchmark::PriorityLevel::HIGH);
BENCHMARK(DeserializeBlockBench, benchmark::PriorityLevel::HIGH);
BENCHMARK(DeserializeAndCheckBlock, benchmark::PriorityLevel::HIGH);