[libcxx-commits] [PATCH] D150747: [libc++][ranges] Add benchmarks for the `from_range` constructors of `vector` and `deque`.

Konstantin Varlamov via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Aug 31 23:44:38 PDT 2023


var-const updated this revision to Diff 555279.
var-const added a comment.

Fix CI


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150747/new/

https://reviews.llvm.org/D150747

Files:
  libcxx/benchmarks/CMakeLists.txt
  libcxx/benchmarks/ContainerBenchmarks.h
  libcxx/benchmarks/deque.bench.cpp
  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
@@ -30,4 +30,13 @@
 BENCHMARK_CAPTURE(BM_ConstructIterIter, vector_string, std::vector<std::string>{}, getRandomStringInputs)
     ->Arg(TestNumInputs);
 
+BENCHMARK_CAPTURE(BM_ConstructFromRange, vector_char, std::vector<char>{}, getRandomIntegerInputs<char>)
+    ->Arg(TestNumInputs);
+
+BENCHMARK_CAPTURE(BM_ConstructFromRange, vector_size_t, std::vector<size_t>{}, getRandomIntegerInputs<size_t>)
+    ->Arg(TestNumInputs);
+
+BENCHMARK_CAPTURE(BM_ConstructFromRange, vector_string, std::vector<std::string>{}, getRandomStringInputs)
+    ->Arg(TestNumInputs);
+
 BENCHMARK_MAIN();
Index: libcxx/benchmarks/deque.bench.cpp
===================================================================
--- libcxx/benchmarks/deque.bench.cpp
+++ libcxx/benchmarks/deque.bench.cpp
@@ -30,4 +30,13 @@
 BENCHMARK_CAPTURE(BM_ConstructIterIter, deque_string, std::deque<std::string>{}, getRandomStringInputs)
     ->Arg(TestNumInputs);
 
+BENCHMARK_CAPTURE(BM_ConstructFromRange, deque_char, std::deque<char>{}, getRandomIntegerInputs<char>)
+    ->Arg(TestNumInputs);
+
+BENCHMARK_CAPTURE(BM_ConstructFromRange, deque_size_t, std::deque<size_t>{}, getRandomIntegerInputs<size_t>)
+    ->Arg(TestNumInputs);
+
+BENCHMARK_CAPTURE(BM_ConstructFromRange, deque_string, std::deque<std::string>{}, getRandomStringInputs)
+    ->Arg(TestNumInputs);
+
 BENCHMARK_MAIN();
Index: libcxx/benchmarks/ContainerBenchmarks.h
===================================================================
--- libcxx/benchmarks/ContainerBenchmarks.h
+++ libcxx/benchmarks/ContainerBenchmarks.h
@@ -69,6 +69,16 @@
   }
 }
 
+template <class Container, class GenInputs>
+void BM_ConstructFromRange(benchmark::State& st, Container, GenInputs gen) {
+  auto in = gen(st.range(0));
+  benchmark::DoNotOptimize(&in);
+  while (st.KeepRunning()) {
+    Container c(std::from_range, in);
+    DoNotOptimizeData(c);
+  }
+}
+
 template <class Container, class GenInputs>
 void BM_InsertValue(benchmark::State& st, Container c, GenInputs gen) {
   auto in        = gen(st.range(0));
Index: libcxx/benchmarks/CMakeLists.txt
===================================================================
--- libcxx/benchmarks/CMakeLists.txt
+++ libcxx/benchmarks/CMakeLists.txt
@@ -76,7 +76,7 @@
 set(BENCHMARK_NATIVE_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/benchmark-native)
 
 add_library(               cxx-benchmarks-flags INTERFACE)
-target_compile_features(   cxx-benchmarks-flags INTERFACE cxx_std_20)
+
 target_compile_options(    cxx-benchmarks-flags INTERFACE -fsized-deallocation -nostdinc++)
 target_include_directories(cxx-benchmarks-flags INTERFACE "${LIBCXX_GENERATED_INCLUDE_DIR}"
                                                 INTERFACE "${BENCHMARK_LIBCXX_INSTALL}/include"
@@ -126,7 +126,10 @@
     PROPERTIES
           OUTPUT_NAME "${name}.libcxx.out"
           RUNTIME_OUTPUT_DIRECTORY "${BENCHMARK_OUTPUT_DIR}"
+          CXX_STANDARD 23
+          CXX_STANDARD_REQUIRED YES
           CXX_EXTENSIONS NO)
+
   cxx_link_system_libraries(${libcxx_target})
   if (LIBCXX_BENCHMARK_NATIVE_STDLIB)
     set(native_target ${name}_native)
@@ -143,6 +146,8 @@
       PROPERTIES
           OUTPUT_NAME "${name}.native.out"
           RUNTIME_OUTPUT_DIRECTORY "${BENCHMARK_OUTPUT_DIR}"
+          CXX_STANDARD 23
+          CXX_STANDARD_REQUIRED YES
           CXX_EXTENSIONS NO)
   endif()
 endfunction()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150747.555279.patch
Type: text/x-patch
Size: 3576 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230901/f926de96/attachment.bin>


More information about the libcxx-commits mailing list