| 33 | } |
| 34 | |
| 35 | static void DeserializeAndCheckBlockTest(benchmark::State& state) |
| 36 | { |
| 37 | CDataStream stream((const char*)block_bench::block413567, |
| 38 | (const char*)&block_bench::block413567[sizeof(block_bench::block413567)], |
| 39 | SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_BLOCK_LEGACY); |
| 40 | char a = '\0'; |
| 41 | stream.write(&a, 1); // Prevent compaction |
| 42 | |
| 43 | const auto chainParams = CreateChainParams(CBaseChainParams::MAIN); |
| 44 | |
| 45 | while (state.KeepRunning()) { |
| 46 | CBlock block; // Note that CBlock caches its checked state, so we need to recreate it here |
| 47 | stream >> block; |
| 48 | assert(stream.Rewind(sizeof(block_bench::block413567))); |
| 49 | |
| 50 | CValidationState validationState; |
| 51 | assert(CheckBlock(block, validationState, chainParams->GetConsensus())); |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | BENCHMARK(DeserializeBlockTest, 130); |
| 56 | BENCHMARK(DeserializeAndCheckBlockTest, 160); |
nothing calls this directly
no test coverage detected