diff --git a/libcxx/benchmarks/CMakeLists.txt b/libcxx/benchmarks/CMakeLists.txt --- a/libcxx/benchmarks/CMakeLists.txt +++ b/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() diff --git a/libcxx/benchmarks/ContainerBenchmarks.h b/libcxx/benchmarks/ContainerBenchmarks.h --- a/libcxx/benchmarks/ContainerBenchmarks.h +++ b/libcxx/benchmarks/ContainerBenchmarks.h @@ -69,6 +69,16 @@ } } +template +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 void BM_InsertValue(benchmark::State& st, Container c, GenInputs gen) { auto in = gen(st.range(0)); diff --git a/libcxx/benchmarks/deque.bench.cpp b/libcxx/benchmarks/deque.bench.cpp --- a/libcxx/benchmarks/deque.bench.cpp +++ b/libcxx/benchmarks/deque.bench.cpp @@ -30,4 +30,19 @@ BENCHMARK_CAPTURE(BM_ConstructIterIter, deque_string, std::deque{}, getRandomStringInputs) ->Arg(TestNumInputs); +BENCHMARK_CAPTURE(BM_ConstructFromRange, + deque_char, + std::deque{}, + getRandomIntegerInputs)->Arg(TestNumInputs); + +BENCHMARK_CAPTURE(BM_ConstructFromRange, + deque_size_t, + std::deque{}, + getRandomIntegerInputs)->Arg(TestNumInputs); + +BENCHMARK_CAPTURE(BM_ConstructFromRange, + deque_string, + std::deque{}, + getRandomStringInputs)->Arg(TestNumInputs); + BENCHMARK_MAIN(); diff --git a/libcxx/benchmarks/vector_operations.bench.cpp b/libcxx/benchmarks/vector_operations.bench.cpp --- a/libcxx/benchmarks/vector_operations.bench.cpp +++ b/libcxx/benchmarks/vector_operations.bench.cpp @@ -30,4 +30,19 @@ BENCHMARK_CAPTURE(BM_ConstructIterIter, vector_string, std::vector{}, getRandomStringInputs) ->Arg(TestNumInputs); +BENCHMARK_CAPTURE(BM_ConstructFromRange, + vector_char, + std::vector{}, + getRandomIntegerInputs)->Arg(TestNumInputs); + +BENCHMARK_CAPTURE(BM_ConstructFromRange, + vector_size_t, + std::vector{}, + getRandomIntegerInputs)->Arg(TestNumInputs); + +BENCHMARK_CAPTURE(BM_ConstructFromRange, + vector_string, + std::vector{}, + getRandomStringInputs)->Arg(TestNumInputs); + BENCHMARK_MAIN();