From ce3e6a7cb21d1aa455513970846e1f70c01472a4 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Fri, 14 Aug 2020 14:56:18 +0300 Subject: bench: Allow skip benchmark Co-authored-by: Martin Ankerl --- src/bench/bench.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/bench') diff --git a/src/bench/bench.cpp b/src/bench/bench.cpp index 01466d0b6f..012057e792 100644 --- a/src/bench/bench.cpp +++ b/src/bench/bench.cpp @@ -70,7 +70,10 @@ void benchmark::BenchRunner::RunAll(const Args& args) } std::cout << bench.complexityBigO() << std::endl; } - benchmarkResults.push_back(bench.results().back()); + + if (!bench.results().empty()) { + benchmarkResults.push_back(bench.results().back()); + } } GenerateTemplateResults(benchmarkResults, args.output_csv, "# Benchmark, evals, iterations, total, min, max, median\n" -- cgit v1.2.3 From 3edc4e34fe2f92e7066c1455f5e42af2fdb43b99 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Fri, 14 Aug 2020 14:58:27 +0300 Subject: bench: Prevent thread oversubscription This change decreases the variance of benchmark results. --- src/bench/checkqueue.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/bench') diff --git a/src/bench/checkqueue.cpp b/src/bench/checkqueue.cpp index 19d7bc0dbc..ffa772d8c1 100644 --- a/src/bench/checkqueue.cpp +++ b/src/bench/checkqueue.cpp @@ -14,8 +14,6 @@ #include - -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; @@ -26,6 +24,9 @@ static const unsigned int QUEUE_BATCH_SIZE = 128; // and there is a little bit of work done between calls to Add. static void CCheckQueueSpeedPrevectorJob(benchmark::Bench& bench) { + // We shouldn't ever be running with the checkqueue on a single core machine. + if (GetNumCores() <= 1) return; + const ECCVerifyHandle verify_handle; ECC_Start(); @@ -44,7 +45,9 @@ static void CCheckQueueSpeedPrevectorJob(benchmark::Bench& bench) }; CCheckQueue queue {QUEUE_BATCH_SIZE}; boost::thread_group tg; - for (auto x = 0; x < std::max(MIN_CORES, GetNumCores()); ++x) { + // The main thread should be counted to prevent thread oversubscription, and + // to decrease the variance of benchmark results. + for (auto x = 0; x < GetNumCores() - 1; ++x) { tg.create_thread([&]{queue.Thread();}); } -- cgit v1.2.3