summaryrefslogtreecommitdiffstats
path: root/libcxx/benchmarks
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/benchmarks')
-rw-r--r--libcxx/benchmarks/ContainerBenchmarks.hpp17
-rw-r--r--libcxx/benchmarks/vector_operations.bench.cpp8
2 files changed, 25 insertions, 0 deletions
diff --git a/libcxx/benchmarks/ContainerBenchmarks.hpp b/libcxx/benchmarks/ContainerBenchmarks.hpp
index 509e3d23ed9..648617a9cd2 100644
--- a/libcxx/benchmarks/ContainerBenchmarks.hpp
+++ b/libcxx/benchmarks/ContainerBenchmarks.hpp
@@ -7,6 +7,23 @@
namespace ContainerBenchmarks {
+template <class Container>
+void BM_ConstructSize(benchmark::State& st, Container) {
+ auto size = st.range(0);
+ for (auto _ : st) {
+ Container c(size);
+ benchmark::DoNotOptimize(c.data());
+ }
+}
+
+template <class Container>
+void BM_ConstructSizeValue(benchmark::State& st, Container, typename Container::value_type const& val) {
+ const auto size = st.range(0);
+ for (auto _ : st) {
+ Container c(size, val);
+ benchmark::DoNotOptimize(c.data());
+ }
+}
template <class Container, class GenInputs>
void BM_ConstructIterIter(benchmark::State& st, Container, GenInputs gen) {
diff --git a/libcxx/benchmarks/vector_operations.bench.cpp b/libcxx/benchmarks/vector_operations.bench.cpp
index a2c4e5dbbc0..c41259eaac3 100644
--- a/libcxx/benchmarks/vector_operations.bench.cpp
+++ b/libcxx/benchmarks/vector_operations.bench.cpp
@@ -13,6 +13,14 @@ using namespace ContainerBenchmarks;
constexpr std::size_t TestNumInputs = 1024;
+BENCHMARK_CAPTURE(BM_ConstructSize,
+ vector_byte,
+ std::vector<unsigned char>{})->Arg(5140480);
+
+BENCHMARK_CAPTURE(BM_ConstructSizeValue,
+ vector_byte,
+ std::vector<unsigned char>{}, 0)->Arg(5140480);
+
BENCHMARK_CAPTURE(BM_ConstructIterIter,
vector_char,
std::vector<char>{},
OpenPOWER on IntegriCloud