aboutsummaryrefslogtreecommitdiff
path: root/src/bench/checkqueue.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <[email protected]>2017-12-23 14:46:20 +0100
committerWladimir J. van der Laan <[email protected]>2017-12-23 14:53:05 +0100
commit5180a86c96bc05d2a731f70f36aae28ab5a3fad4 (patch)
tree2339b7b14ec174861d1baa73a44a33680644f820 /src/bench/checkqueue.cpp
parentMerge #11748: [Tests] Adding unit tests for GetDifficulty in blockchain.cpp. (diff)
parentRemoved CCheckQueueSpeed benchmark (diff)
downloaddiscoin-5180a86c96bc05d2a731f70f36aae28ab5a3fad4.tar.xz
discoin-5180a86c96bc05d2a731f70f36aae28ab5a3fad4.zip
Merge #11517: Tests: Improve benchmark precision
760af84 Removed CCheckQueueSpeed benchmark (Martin Ankerl) 00721e6 Improved microbenchmarking with multiple features. (Martin Ankerl) Pull request description: The benchmark's KeepRunning() used to make a function call for each call, inflating measurement times for short running code. This change inlines the critical code that is executed each run and moves the slow timer updates into a new function. This change increases the average runtime for Trig from 0.000000082339208 sec to 0.000000080948591. Tree-SHA512: 36b3bc55fc9b1d4cbf526b7103af6af18e9783e6b8f3ad3adbd09fac0bf9401cfefad58fd1e6fa2615d3c4e677998f912f3323d61d7b00b1c660d581c257d577
Diffstat (limited to 'src/bench/checkqueue.cpp')
-rw-r--r--src/bench/checkqueue.cpp43
1 files changed, 1 insertions, 42 deletions
diff --git a/src/bench/checkqueue.cpp b/src/bench/checkqueue.cpp
index 35750aa1b..4d41e28db 100644
--- a/src/bench/checkqueue.cpp
+++ b/src/bench/checkqueue.cpp
@@ -12,51 +12,11 @@
#include <random.h>
-// This Benchmark tests the CheckQueue with the lightest
-// weight Checks, so it should make any lock contention
-// particularly visible
static const int MIN_CORES = 2;
static const size_t BATCHES = 101;
static const size_t BATCH_SIZE = 30;
static const int PREVECTOR_SIZE = 28;
static const unsigned int QUEUE_BATCH_SIZE = 128;
-static void CCheckQueueSpeed(benchmark::State& state)
-{
- struct FakeJobNoWork {
- bool operator()()
- {
- return true;
- }
- void swap(FakeJobNoWork& x){};
- };
- CCheckQueue<FakeJobNoWork> queue {QUEUE_BATCH_SIZE};
- boost::thread_group tg;
- for (auto x = 0; x < std::max(MIN_CORES, GetNumCores()); ++x) {
- tg.create_thread([&]{queue.Thread();});
- }
- while (state.KeepRunning()) {
- CCheckQueueControl<FakeJobNoWork> control(&queue);
-
- // We call Add a number of times to simulate the behavior of adding
- // a block of transactions at once.
-
- std::vector<std::vector<FakeJobNoWork>> vBatches(BATCHES);
- for (auto& vChecks : vBatches) {
- vChecks.resize(BATCH_SIZE);
- }
- for (auto& vChecks : vBatches) {
- // We can't make vChecks in the inner loop because we want to measure
- // the cost of getting the memory to each thread and we might get the same
- // memory
- control.Add(vChecks);
- }
- // control waits for completion by RAII, but
- // it is done explicitly here for clarity
- control.Wait();
- }
- tg.interrupt_all();
- tg.join_all();
-}
// This Benchmark tests the CheckQueue with a slightly realistic workload,
// where checks all contain a prevector that is indirect 50% of the time
@@ -99,5 +59,4 @@ static void CCheckQueueSpeedPrevectorJob(benchmark::State& state)
tg.interrupt_all();
tg.join_all();
}
-BENCHMARK(CCheckQueueSpeed);
-BENCHMARK(CCheckQueueSpeedPrevectorJob);
+BENCHMARK(CCheckQueueSpeedPrevectorJob, 1400);