aboutsummaryrefslogtreecommitdiff
path: root/src/bench
diff options
context:
space:
mode:
authorfurszy <matiasfurszyfer@protonmail.com>2024-09-29 14:21:49 -0300
committerfurszy <matiasfurszyfer@protonmail.com>2024-11-11 11:31:04 -0500
commitad9c2cceda9cd893c0f754e49f7fca6e417ee95f (patch)
tree406d76ef64f138bf0f5b14d5b588fbe82c8114cc /src/bench
parent2c90f8e08c4cf44d4c1ef3dde0e7f7991b8b9390 (diff)
test, bench: specialize working directory name
Since G_TEST_GET_FULL_NAME is not initialized in the benchmark framework, benchmarks using the unit test setup run in the same directory without any clear distinction between them. This poses an extra complication for locating any specific benchmark directory during a failure. In master, unit tests and benchmarks run in the following path: /<OS_tmp_dir>/test_common bitcoin/<random_uint256>/ After this commit, unit tests and benchmarks are contained within its own directory: /<OS_tmp_dir>/test_common bitcoin/<test_name>/<time_in_nanoseconds>/ This makes it easier to find any benchmark run when a failure occurs.
Diffstat (limited to 'src/bench')
-rw-r--r--src/bench/bench.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/bench/bench.cpp b/src/bench/bench.cpp
index a2dbb11888..d6913a05f2 100644
--- a/src/bench/bench.cpp
+++ b/src/bench/bench.cpp
@@ -29,7 +29,16 @@ const std::function<void(const std::string&)> G_TEST_LOG_FUN{};
const std::function<std::vector<const char*>()> G_TEST_COMMAND_LINE_ARGUMENTS{};
-const std::function<std::string()> G_TEST_GET_FULL_NAME{};
+/**
+ * Retrieve the name of the currently in-use benchmark.
+ * This is applicable only to benchmarks that utilize the unit test
+ * framework context setup (e.g. ones using 'MakeNoLogFileContext<TestingSetup>()').
+ * It places the datadir of each benchmark run within their respective benchmark name.
+ */
+static std::string g_running_benchmark_name;
+const std::function<std::string()> G_TEST_GET_FULL_NAME = []() {
+ return g_running_benchmark_name;
+};
namespace {
@@ -117,6 +126,7 @@ void BenchRunner::RunAll(const Args& args)
bench.output(nullptr);
}
bench.name(name);
+ g_running_benchmark_name = name;
if (args.min_time > 0ms) {
// convert to nanos before dividing to reduce rounding errors
std::chrono::nanoseconds min_time_ns = args.min_time;