From 00721e69f8280f8bc59bede43b335ecc347d4fdf Mon Sep 17 00:00:00 2001 From: Martin Ankerl Date: Tue, 17 Oct 2017 16:48:02 +0200 Subject: Improved microbenchmarking with multiple features. * inline performance critical code * Average runtime is specified and used to calculate iterations. * Console: show median of multiple runs * plot: show box plot * filter benchmarks * specify scaling factor * ignore src/test and src/bench in command line check script * number of iterations instead of time * Replaced runtime in BENCHMARK makro number of iterations. * Added -? to bench_bitcoin * Benchmark plotly.js URL, width, height can be customized * Fixed incorrect precision warning --- src/bench/checkqueue.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/bench/checkqueue.cpp') diff --git a/src/bench/checkqueue.cpp b/src/bench/checkqueue.cpp index 35750aa1b..e79c98679 100644 --- a/src/bench/checkqueue.cpp +++ b/src/bench/checkqueue.cpp @@ -99,5 +99,5 @@ static void CCheckQueueSpeedPrevectorJob(benchmark::State& state) tg.interrupt_all(); tg.join_all(); } -BENCHMARK(CCheckQueueSpeed); -BENCHMARK(CCheckQueueSpeedPrevectorJob); +BENCHMARK(CCheckQueueSpeed, 29000); +BENCHMARK(CCheckQueueSpeedPrevectorJob, 1400); -- cgit v1.2.3 From 760af84072408ba53d009e868fccc25fb186d40c Mon Sep 17 00:00:00 2001 From: Martin Ankerl Date: Wed, 20 Dec 2017 19:53:28 +0100 Subject: Removed CCheckQueueSpeed benchmark This benchmark's runtime was rather unpredictive on different machines, not really a useful benchmark. --- src/bench/checkqueue.cpp | 41 ----------------------------------------- 1 file changed, 41 deletions(-) (limited to 'src/bench/checkqueue.cpp') diff --git a/src/bench/checkqueue.cpp b/src/bench/checkqueue.cpp index e79c98679..4d41e28db 100644 --- a/src/bench/checkqueue.cpp +++ b/src/bench/checkqueue.cpp @@ -12,51 +12,11 @@ #include -// 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 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 control(&queue); - - // We call Add a number of times to simulate the behavior of adding - // a block of transactions at once. - - std::vector> 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, 29000); BENCHMARK(CCheckQueueSpeedPrevectorJob, 1400); -- cgit v1.2.3