|
2 | 2 | // Distributed under the MIT software license, see the accompanying |
3 | 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. |
4 | 4 |
|
5 | | -#include "bench.h" |
| 5 | +#include "bench/bench.h" |
| 6 | +#include "bench/data.h" |
6 | 7 |
|
7 | 8 | #include "validation.h" |
8 | 9 |
|
9 | | -namespace block_bench { |
10 | | -#include "bench/data/block2680960.raw.h" |
11 | | -} |
12 | | - |
13 | 10 | // These are the two major time-sinks which happen after we have fully received |
14 | 11 | // a block off the wire, but before we can relay the block on to peers using |
15 | 12 | // compact block relay. |
16 | 13 |
|
17 | 14 | static void DeserializeBlockTest(benchmark::State& state) |
18 | 15 | { |
19 | | - CDataStream stream((const char*)block_bench::block2680960, |
20 | | - (const char*)&block_bench::block2680960[sizeof(block_bench::block2680960)], |
21 | | - SER_NETWORK, PROTOCOL_VERSION); |
22 | | - char a; |
| 16 | + CDataStream stream(benchmark::data::block2680960, SER_NETWORK, PROTOCOL_VERSION); |
| 17 | + char a = '\0'; |
23 | 18 | stream.write(&a, 1); // Prevent compaction |
24 | 19 |
|
25 | 20 | while (state.KeepRunning()) { |
26 | 21 | CBlock block; |
27 | 22 | stream >> block; |
28 | | - assert(stream.Rewind(sizeof(block_bench::block2680960))); |
| 23 | + bool rewound = stream.Rewind(benchmark::data::block2680960.size()); |
| 24 | + assert(rewound); |
29 | 25 | } |
30 | 26 | } |
31 | 27 |
|
32 | 28 | static void DeserializeAndCheckBlockTest(benchmark::State& state) |
33 | 29 | { |
34 | | - CDataStream stream((const char*)block_bench::block2680960, |
35 | | - (const char*)&block_bench::block2680960[sizeof(block_bench::block2680960)], |
36 | | - SER_NETWORK, PROTOCOL_VERSION); |
37 | | - char a; |
| 30 | + CDataStream stream(benchmark::data::block2680960, SER_NETWORK, PROTOCOL_VERSION); |
| 31 | + char a = '\0'; |
38 | 32 | stream.write(&a, 1); // Prevent compaction |
39 | 33 |
|
40 | 34 | SelectParams(CBaseChainParams::MAIN); |
41 | 35 |
|
42 | 36 | while (state.KeepRunning()) { |
43 | 37 | CBlock block; // Note that CBlock caches its checked state, so we need to recreate it here |
44 | 38 | stream >> block; |
45 | | - assert(stream.Rewind(sizeof(block_bench::block2680960))); |
| 39 | + bool rewound = stream.Rewind(benchmark::data::block2680960.size()); |
| 40 | + assert(rewound); |
46 | 41 |
|
47 | 42 | CValidationState state; |
48 | 43 | assert(CheckBlock(block, state)); |
|
0 commit comments