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

summaryrefslogtreecommitdiffhomepage
path: root/tests/SelfTest/UsageTests
diff options
context:
space:
mode:
authorJoe Burzinski2019-11-18 22:22:38 -0600
committerMartin Hořeňovský2020-02-13 16:15:50 +0100
commit0fbf4f3e152e8fe9a41fa1a960ea3dac3cb76e59 (patch)
treed533f0a4066aab4cef66f4252d529454ab05a6cf /tests/SelfTest/UsageTests
parentad3f50bbc1ad66bf9ad5005d1a5f52eb6b28972f (diff)
downloadcatch3-0fbf4f3e152e8fe9a41fa1a960ea3dac3cb76e59.tar.gz
Fix wrong namespacing of benchmarking constructor helpers
Diffstat (limited to 'tests/SelfTest/UsageTests')
-rw-r--r--tests/SelfTest/UsageTests/Benchmark.tests.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/SelfTest/UsageTests/Benchmark.tests.cpp b/tests/SelfTest/UsageTests/Benchmark.tests.cpp
index fe2d736c..38ad6a9f 100644
--- a/tests/SelfTest/UsageTests/Benchmark.tests.cpp
+++ b/tests/SelfTest/UsageTests/Benchmark.tests.cpp
@@ -1,5 +1,6 @@
#include <catch2/catch_test_macros.hpp>
#include <catch2/benchmark/catch_benchmark.hpp>
+#include <catch2/benchmark/catch_constructor.hpp>
#include <catch2/catch_generators_specific.hpp>
#include <map>
@@ -127,4 +128,18 @@ TEST_CASE("Benchmark containers", "[!benchmark]") {
REQUIRE(v[i] == generated);
}
}
+
+ SECTION("construct and destroy example") {
+ BENCHMARK_ADVANCED("construct")(Catch::Benchmark::Chronometer meter) {
+ std::vector<Catch::Benchmark::storage_for<std::string>> storage(meter.runs());
+ meter.measure([&](int i) { storage[i].construct("thing"); });
+ };
+
+ BENCHMARK_ADVANCED("destroy")(Catch::Benchmark::Chronometer meter) {
+ std::vector<Catch::Benchmark::destructable_object<std::string>> storage(meter.runs());
+ for(auto&& o : storage)
+ o.construct("thing");
+ meter.measure([&](int i) { storage[i].destruct(); });
+ };
+ }
}