|
12 | 12 | #include <random.h>
|
13 | 13 |
|
14 | 14 |
|
15 |
| -// This Benchmark tests the CheckQueue with the lightest |
16 |
| -// weight Checks, so it should make any lock contention |
17 |
| -// particularly visible |
18 | 15 | static const int MIN_CORES = 2;
|
19 | 16 | static const size_t BATCHES = 101;
|
20 | 17 | static const size_t BATCH_SIZE = 30;
|
21 | 18 | static const int PREVECTOR_SIZE = 28;
|
22 | 19 | static const unsigned int QUEUE_BATCH_SIZE = 128;
|
23 |
| -static void CCheckQueueSpeed(benchmark::State& state) |
24 |
| -{ |
25 |
| - struct FakeJobNoWork { |
26 |
| - bool operator()() |
27 |
| - { |
28 |
| - return true; |
29 |
| - } |
30 |
| - void swap(FakeJobNoWork& x){}; |
31 |
| - }; |
32 |
| - CCheckQueue<FakeJobNoWork> queue {QUEUE_BATCH_SIZE}; |
33 |
| - boost::thread_group tg; |
34 |
| - for (auto x = 0; x < std::max(MIN_CORES, GetNumCores()); ++x) { |
35 |
| - tg.create_thread([&]{queue.Thread();}); |
36 |
| - } |
37 |
| - while (state.KeepRunning()) { |
38 |
| - CCheckQueueControl<FakeJobNoWork> control(&queue); |
39 |
| - |
40 |
| - // We call Add a number of times to simulate the behavior of adding |
41 |
| - // a block of transactions at once. |
42 |
| - |
43 |
| - std::vector<std::vector<FakeJobNoWork>> vBatches(BATCHES); |
44 |
| - for (auto& vChecks : vBatches) { |
45 |
| - vChecks.resize(BATCH_SIZE); |
46 |
| - } |
47 |
| - for (auto& vChecks : vBatches) { |
48 |
| - // We can't make vChecks in the inner loop because we want to measure |
49 |
| - // the cost of getting the memory to each thread and we might get the same |
50 |
| - // memory |
51 |
| - control.Add(vChecks); |
52 |
| - } |
53 |
| - // control waits for completion by RAII, but |
54 |
| - // it is done explicitly here for clarity |
55 |
| - control.Wait(); |
56 |
| - } |
57 |
| - tg.interrupt_all(); |
58 |
| - tg.join_all(); |
59 |
| -} |
60 | 20 |
|
61 | 21 | // This Benchmark tests the CheckQueue with a slightly realistic workload,
|
62 | 22 | // where checks all contain a prevector that is indirect 50% of the time
|
@@ -99,5 +59,4 @@ static void CCheckQueueSpeedPrevectorJob(benchmark::State& state)
|
99 | 59 | tg.interrupt_all();
|
100 | 60 | tg.join_all();
|
101 | 61 | }
|
102 |
| -BENCHMARK(CCheckQueueSpeed, 29000); |
103 | 62 | BENCHMARK(CCheckQueueSpeedPrevectorJob, 1400);
|
0 commit comments