[libcxx-commits] [PATCH] D148850: Add test case for vector copy
Aditya Kumar via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Apr 20 15:29:44 PDT 2023
hiraditya created this revision.
hiraditya added reviewers: ldionne, EricWF, philnik, libc++.
Herald added a project: All.
hiraditya requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added 1 blocking reviewer(s): libc++.
Reported in: https://github.com/llvm/llvm-project/issues/61987
Fix proposed in: https://reviews.llvm.org/D147741
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D148850
Files:
libcxx/benchmarks/ContainerBenchmarks.h
libcxx/benchmarks/vector_operations.bench.cpp
Index: libcxx/benchmarks/vector_operations.bench.cpp
===================================================================
--- libcxx/benchmarks/vector_operations.bench.cpp
+++ libcxx/benchmarks/vector_operations.bench.cpp
@@ -17,6 +17,10 @@
vector_byte,
std::vector<unsigned char>{})->Arg(5140480);
+BENCHMARK_CAPTURE(BM_CopyConstruct,
+ vector_int,
+ std::vector<int>{})->Arg(5140480);
+
BENCHMARK_CAPTURE(BM_ConstructSizeValue,
vector_byte,
std::vector<unsigned char>{}, 0)->Arg(5140480);
Index: libcxx/benchmarks/ContainerBenchmarks.h
===================================================================
--- libcxx/benchmarks/ContainerBenchmarks.h
+++ libcxx/benchmarks/ContainerBenchmarks.h
@@ -26,6 +26,23 @@
}
}
+template <class Container>
+__attribute__((noinline))
+int CopyContainer(Container v1) {
+ auto v = v1;
+ return 0;
+}
+
+template <class Container>
+void BM_CopyConstruct(benchmark::State& st, Container) {
+ auto size = st.range(0);
+ for (auto _ : st) {
+ Container c(size);
+ auto v = CopyContainer(c);
+ DoNotOptimizeData(v);
+ }
+}
+
template <class Container>
void BM_ConstructSizeValue(benchmark::State& st, Container, typename Container::value_type const& val) {
const auto size = st.range(0);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148850.515509.patch
Type: text/x-patch
Size: 1277 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230420/8f1ea7f1/attachment.bin>
More information about the libcxx-commits
mailing list