[trivial] Add end of namespace comments
[bitcoinplatinum.git] / src / bench / checkblock.cpp
blob30900d854a80bbcc779e3ebeef5448595eab1872
1 // Copyright (c) 2016 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.
5 #include "bench.h"
7 #include "chainparams.h"
8 #include "validation.h"
9 #include "streams.h"
10 #include "consensus/validation.h"
12 namespace block_bench {
13 #include "bench/data/block413567.raw.h"
14 } // namespace block_bench
16 // These are the two major time-sinks which happen after we have fully received
17 // a block off the wire, but before we can relay the block on to peers using
18 // compact block relay.
20 static void DeserializeBlockTest(benchmark::State& state)
22 CDataStream stream((const char*)block_bench::block413567,
23 (const char*)&block_bench::block413567[sizeof(block_bench::block413567)],
24 SER_NETWORK, PROTOCOL_VERSION);
25 char a = '\0';
26 stream.write(&a, 1); // Prevent compaction
28 while (state.KeepRunning()) {
29 CBlock block;
30 stream >> block;
31 assert(stream.Rewind(sizeof(block_bench::block413567)));
35 static void DeserializeAndCheckBlockTest(benchmark::State& state)
37 CDataStream stream((const char*)block_bench::block413567,
38 (const char*)&block_bench::block413567[sizeof(block_bench::block413567)],
39 SER_NETWORK, PROTOCOL_VERSION);
40 char a = '\0';
41 stream.write(&a, 1); // Prevent compaction
43 Consensus::Params params = Params(CBaseChainParams::MAIN).GetConsensus();
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)));
50 CValidationState validationState;
51 assert(CheckBlock(block, validationState, params));
55 BENCHMARK(DeserializeBlockTest);
56 BENCHMARK(DeserializeAndCheckBlockTest);