diff options
author | Martin Ankerl <martin.ankerl@gmail.com> | 2021-09-18 08:38:20 +0200 |
---|---|---|
committer | Martin Ankerl <martin.ankerl@gmail.com> | 2021-09-21 14:45:48 +0200 |
commit | d3c6f8bfa12f78635752878b28e66cec0c85d4a9 (patch) | |
tree | aa0c96f88435e0ec8bda3610653c471bec7ff509 /src/bench/bench_bitcoin.cpp | |
parent | 9fef8329322277d9c14c8df1867cb3c61477c431 (diff) | |
download | bitcoin-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_bitcoin.cpp')
-rw-r--r-- | src/bench/bench_bitcoin.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/bench/bench_bitcoin.cpp b/src/bench/bench_bitcoin.cpp index aab777cac1..ae1e930bb7 100644 --- a/src/bench/bench_bitcoin.cpp +++ b/src/bench/bench_bitcoin.cpp @@ -11,6 +11,7 @@ #include <memory> static const char* DEFAULT_BENCH_FILTER = ".*"; +static constexpr int64_t DEFAULT_MIN_TIME_MS{10}; static void SetupBenchArgs(ArgsManager& argsman) { @@ -19,6 +20,7 @@ static void SetupBenchArgs(ArgsManager& argsman) argsman.AddArg("-asymptote=n1,n2,n3,...", "Test asymptotic growth of the runtime of an algorithm, if supported by the benchmark", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); argsman.AddArg("-filter=<regex>", strprintf("Regular expression filter to select benchmark by name (default: %s)", DEFAULT_BENCH_FILTER), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); argsman.AddArg("-list", "List benchmarks without executing them", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); + argsman.AddArg("-min_time=<milliseconds>", strprintf("Minimum runtime per benchmark, in milliseconds (default: %d)", DEFAULT_MIN_TIME_MS), ArgsManager::ALLOW_INT, OptionsCategory::OPTIONS); argsman.AddArg("-output_csv=<output.csv>", "Generate CSV file with the most important benchmark results", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); argsman.AddArg("-output_json=<output.json>", "Generate JSON file with all benchmark results", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); } @@ -57,6 +59,7 @@ int main(int argc, char** argv) args.regex_filter = argsman.GetArg("-filter", DEFAULT_BENCH_FILTER); args.is_list_only = argsman.GetBoolArg("-list", false); args.asymptote = parseAsymptote(argsman.GetArg("-asymptote", "")); + args.min_time = std::chrono::milliseconds(argsman.GetArg("-min_time", DEFAULT_MIN_TIME_MS)); args.output_csv = argsman.GetArg("-output_csv", ""); args.output_json = argsman.GetArg("-output_json", ""); |