mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-08-25 00:51:17 +02:00
bench: Add --sanity-check
flag, use it in make check
The benchmarks are run as part of `make check` for a minimum sanity check. The actual results are being ignored. So only run them for one iteration. This makes the `bench_bitcoin` part take 2m00 instead of 5m20 here. Which is still too long (imo), but this needs to be solved in the `WalletLoading*` benchmarks which take that long per iteration.
This commit is contained in:
@@ -364,8 +364,8 @@ endif
|
|||||||
if TARGET_WINDOWS
|
if TARGET_WINDOWS
|
||||||
else
|
else
|
||||||
if ENABLE_BENCH
|
if ENABLE_BENCH
|
||||||
@echo "Running bench/bench_bitcoin ..."
|
@echo "Running bench/bench_bitcoin (one iteration sanity check)..."
|
||||||
$(BENCH_BINARY) > /dev/null
|
$(BENCH_BINARY) --sanity-check > /dev/null
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C secp256k1 check
|
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C secp256k1 check
|
||||||
|
@@ -57,6 +57,10 @@ void benchmark::BenchRunner::RunAll(const Args& args)
|
|||||||
std::regex reFilter(args.regex_filter);
|
std::regex reFilter(args.regex_filter);
|
||||||
std::smatch baseMatch;
|
std::smatch baseMatch;
|
||||||
|
|
||||||
|
if (args.sanity_check) {
|
||||||
|
std::cout << "Running with --sanity check option, benchmark results will be useless." << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<ankerl::nanobench::Result> benchmarkResults;
|
std::vector<ankerl::nanobench::Result> benchmarkResults;
|
||||||
for (const auto& p : benchmarks()) {
|
for (const auto& p : benchmarks()) {
|
||||||
if (!std::regex_match(p.first, baseMatch, reFilter)) {
|
if (!std::regex_match(p.first, baseMatch, reFilter)) {
|
||||||
@@ -69,6 +73,9 @@ void benchmark::BenchRunner::RunAll(const Args& args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Bench bench;
|
Bench bench;
|
||||||
|
if (args.sanity_check) {
|
||||||
|
bench.epochs(1).epochIterations(1);
|
||||||
|
}
|
||||||
bench.name(p.first);
|
bench.name(p.first);
|
||||||
if (args.min_time > 0ms) {
|
if (args.min_time > 0ms) {
|
||||||
// convert to nanos before dividing to reduce rounding errors
|
// convert to nanos before dividing to reduce rounding errors
|
||||||
|
@@ -43,6 +43,7 @@ typedef std::function<void(Bench&)> BenchFunction;
|
|||||||
|
|
||||||
struct Args {
|
struct Args {
|
||||||
bool is_list_only;
|
bool is_list_only;
|
||||||
|
bool sanity_check;
|
||||||
std::chrono::milliseconds min_time;
|
std::chrono::milliseconds min_time;
|
||||||
std::vector<double> asymptote;
|
std::vector<double> asymptote;
|
||||||
fs::path output_csv;
|
fs::path output_csv;
|
||||||
|
@@ -29,6 +29,7 @@ static void SetupBenchArgs(ArgsManager& argsman)
|
|||||||
argsman.AddArg("-min_time=<milliseconds>", strprintf("Minimum runtime per benchmark, in milliseconds (default: %d)", DEFAULT_MIN_TIME_MS), ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_NEGATION, OptionsCategory::OPTIONS);
|
argsman.AddArg("-min_time=<milliseconds>", strprintf("Minimum runtime per benchmark, in milliseconds (default: %d)", DEFAULT_MIN_TIME_MS), ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_NEGATION, 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_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);
|
argsman.AddArg("-output_json=<output.json>", "Generate JSON file with all benchmark results", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
||||||
|
argsman.AddArg("-sanity-check", "Run benchmarks for only one iteration", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
// parses a comma separated list like "10,20,30,50"
|
// parses a comma separated list like "10,20,30,50"
|
||||||
@@ -112,6 +113,7 @@ int main(int argc, char** argv)
|
|||||||
args.output_csv = argsman.GetPathArg("-output_csv");
|
args.output_csv = argsman.GetPathArg("-output_csv");
|
||||||
args.output_json = argsman.GetPathArg("-output_json");
|
args.output_json = argsman.GetPathArg("-output_json");
|
||||||
args.regex_filter = argsman.GetArg("-filter", DEFAULT_BENCH_FILTER);
|
args.regex_filter = argsman.GetArg("-filter", DEFAULT_BENCH_FILTER);
|
||||||
|
args.sanity_check = argsman.GetBoolArg("-sanity-check", false);
|
||||||
|
|
||||||
benchmark::BenchRunner::RunAll(args);
|
benchmark::BenchRunner::RunAll(args);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user