Changeset View
Changeset View
Standalone View
Standalone View
src/bench/checkblock.cpp
Show All 14 Lines | |||||
} // namespace block_bench | } // namespace block_bench | ||||
// These are the two major time-sinks which happen after we have fully received | // These are the two major time-sinks which happen after we have fully received | ||||
// a block off the wire, but before we can relay the block on to peers using | // a block off the wire, but before we can relay the block on to peers using | ||||
// compact block relay. | // compact block relay. | ||||
static void DeserializeBlockTest(benchmark::State &state) { | static void DeserializeBlockTest(benchmark::State &state) { | ||||
CDataStream stream((const char *)block_bench::block413567, | CDataStream stream((const char *)block_bench::block413567, | ||||
(const char *)&block_bench::block413567[sizeof( | (const char *)block_bench::block413567 + | ||||
block_bench::block413567)], | sizeof(block_bench::block413567), | ||||
SER_NETWORK, PROTOCOL_VERSION); | SER_NETWORK, PROTOCOL_VERSION); | ||||
char a = '\0'; | char a = '\0'; | ||||
stream.write(&a, 1); // Prevent compaction | stream.write(&a, 1); // Prevent compaction | ||||
while (state.KeepRunning()) { | while (state.KeepRunning()) { | ||||
CBlock block; | CBlock block; | ||||
stream >> block; | stream >> block; | ||||
bool rewound = stream.Rewind(sizeof(block_bench::block413567)); | bool rewound = stream.Rewind(sizeof(block_bench::block413567)); | ||||
assert(rewound); | assert(rewound); | ||||
} | } | ||||
} | } | ||||
static void DeserializeAndCheckBlockTest(benchmark::State &state) { | static void DeserializeAndCheckBlockTest(benchmark::State &state) { | ||||
CDataStream stream((const char *)block_bench::block413567, | CDataStream stream((const char *)block_bench::block413567, | ||||
(const char *)&block_bench::block413567[sizeof( | (const char *)block_bench::block413567 + | ||||
block_bench::block413567)], | sizeof(block_bench::block413567), | ||||
SER_NETWORK, PROTOCOL_VERSION); | SER_NETWORK, PROTOCOL_VERSION); | ||||
char a = '\0'; | char a = '\0'; | ||||
stream.write(&a, 1); // Prevent compaction | stream.write(&a, 1); // Prevent compaction | ||||
const Config &config = GetConfig(); | const Config &config = GetConfig(); | ||||
const Consensus::Params params = config.GetChainParams().GetConsensus(); | const Consensus::Params params = config.GetChainParams().GetConsensus(); | ||||
BlockValidationOptions options(config); | BlockValidationOptions options(config); | ||||
while (state.KeepRunning()) { | while (state.KeepRunning()) { | ||||
Show All 15 Lines |