Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2
diff options
context:
space:
mode:
authorMartin Hořeňovský2021-08-10 00:33:56 +0200
committerMartin Hořeňovský2021-08-11 22:52:01 +0200
commit2c84854b90f626032c47c88d1bbbc8af2b5bdab4 (patch)
tree3039e57651ad74511871d390e79f02d7274c5704 /src/catch2
parent3579c055c890b525d5e46f81aa9670521da28962 (diff)
downloadcatch3-2c84854b90f626032c47c88d1bbbc8af2b5bdab4.tar.gz
Use unique_ptr to hold Environment measurements in benchmarking
Diffstat (limited to 'src/catch2')
-rw-r--r--src/catch2/benchmark/detail/catch_estimate_clock.hpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/catch2/benchmark/detail/catch_estimate_clock.hpp b/src/catch2/benchmark/detail/catch_estimate_clock.hpp
index 984acd11..3bba791e 100644
--- a/src/catch2/benchmark/detail/catch_estimate_clock.hpp
+++ b/src/catch2/benchmark/detail/catch_estimate_clock.hpp
@@ -16,6 +16,7 @@
#include <catch2/benchmark/detail/catch_measure.hpp>
#include <catch2/benchmark/detail/catch_run_for_at_least.hpp>
#include <catch2/benchmark/catch_clock.hpp>
+#include <catch2/internal/catch_unique_ptr.hpp>
#include <algorithm>
#include <iterator>
@@ -94,7 +95,14 @@ namespace Catch {
template <typename Clock>
Environment<FloatDuration<Clock>> measure_environment() {
- static Environment<FloatDuration<Clock>>* env = nullptr;
+#if defined(__clang__)
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wexit-time-destructors"
+#endif
+ static Catch::Detail::unique_ptr<Environment<FloatDuration<Clock>>> env;
+#if defined(__clang__)
+# pragma clang diagnostic pop
+#endif
if (env) {
return *env;
}
@@ -103,7 +111,7 @@ namespace Catch {
auto resolution = Detail::estimate_clock_resolution<Clock>(iters);
auto cost = Detail::estimate_clock_cost<Clock>(resolution.mean);
- env = new Environment<FloatDuration<Clock>>{ resolution, cost };
+ env = Catch::Detail::make_unique<Environment<FloatDuration<Clock>>>( Environment<FloatDuration<Clock>>{resolution, cost} );
return *env;
}
} // namespace Detail