aboutsummaryrefslogtreecommitdiff
path: root/src/bench/bench.cpp
diff options
context:
space:
mode:
authorMartin Ankerl <martin.ankerl@gmail.com>2021-09-18 08:38:20 +0200
committerMartin Ankerl <martin.ankerl@gmail.com>2021-09-21 14:45:48 +0200
commitd3c6f8bfa12f78635752878b28e66cec0c85d4a9 (patch)
treeaa0c96f88435e0ec8bda3610653c471bec7ff509 /src/bench/bench.cpp
parent9fef8329322277d9c14c8df1867cb3c61477c431 (diff)
downloadbitcoin-d3c6f8bfa12f78635752878b28e66cec0c85d4a9.tar.xz
bench: introduce -min_time argument
When it is not easily possible to stabilize benchmark machine and code the argument -min_time can be used to specify a minimum duration that a benchmark should take. E.g. choose -min_time=1000 if you are willing to wait about 1 second for each benchmark result. The default is now set to 10ms instead of 0, which should make runs on fast machines more stable with negligible slowdown.
Diffstat (limited to 'src/bench/bench.cpp')
-rw-r--r--src/bench/bench.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/bench/bench.cpp b/src/bench/bench.cpp
index 012057e792..335ce8cd45 100644
--- a/src/bench/bench.cpp
+++ b/src/bench/bench.cpp
@@ -61,6 +61,12 @@ void benchmark::BenchRunner::RunAll(const Args& args)
Bench bench;
bench.name(p.first);
+ if (args.min_time > 0ms) {
+ // convert to nanos before dividing to reduce rounding errors
+ std::chrono::nanoseconds min_time_ns = args.min_time;
+ bench.minEpochTime(min_time_ns / bench.epochs());
+ }
+
if (args.asymptote.empty()) {
p.second(bench);
} else {