diff --git a/src/bench/bench_bitcoin.cpp b/src/bench/bench_bitcoin.cpp --- a/src/bench/bench_bitcoin.cpp +++ b/src/bench/bench_bitcoin.cpp @@ -69,6 +69,14 @@ gArgs.AddArg("-help", "", false, OptionsCategory::HIDDEN); } +static fs::path SetDataDir() { + fs::path ret = + fs::temp_directory_path() / "bench_bitcoin" / fs::unique_path(); + fs::create_directories(ret); + gArgs.ForceSetArg("-datadir", ret.string()); + return ret; +} + int main(int argc, char **argv) { SetupBenchArgs(); std::string error; @@ -83,6 +91,9 @@ return EXIT_SUCCESS; } + // Set the datadir after parsing the bench options + const fs::path bench_datadir{SetDataDir()}; + SHA256AutoDetect(); ECC_Start(); SetupEnvironment(); @@ -112,6 +123,8 @@ benchmark::BenchRunner::RunAll(*printer, evaluations, scaling_factor, regex_filter, is_list_only); + fs::remove_all(bench_datadir); + ECC_Stop(); return EXIT_SUCCESS;