Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc++] Explicitly mention vector_bool in the name of benchmarks #127313

Merged
merged 1 commit into from
Feb 15, 2025

Conversation

ldionne
Copy link
Member

@ldionne ldionne commented Feb 15, 2025

We have some benchmarks that were benchmarking very specific functionality, namely the optimizations in vector::iterator. Call this out in the benchmarks by renaming them appropriately. In the future we will also increase the coverage of these benchmarks to test other containers.

We have some benchmarks that were benchmarking very specific functionality,
namely the optimizations in vector<bool>::iterator. Call this out in the
benchmarks by renaming them appropriately. In the future we will also
increase the coverage of these benchmarks to test other containers.
@ldionne ldionne requested a review from a team as a code owner February 15, 2025 11:03
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Feb 15, 2025
@llvmbot
Copy link
Member

llvmbot commented Feb 15, 2025

@llvm/pr-subscribers-libcxx

Author: Louis Dionne (ldionne)

Changes

We have some benchmarks that were benchmarking very specific functionality, namely the optimizations in vector<bool>::iterator. Call this out in the benchmarks by renaming them appropriately. In the future we will also increase the coverage of these benchmarks to test other containers.


Full diff: https://github.com/llvm/llvm-project/pull/127313.diff

2 Files Affected:

  • (modified) libcxx/test/benchmarks/algorithms/fill.bench.cpp (+8-8)
  • (modified) libcxx/test/benchmarks/algorithms/ranges_contains.bench.cpp (+6-6)
diff --git a/libcxx/test/benchmarks/algorithms/fill.bench.cpp b/libcxx/test/benchmarks/algorithms/fill.bench.cpp
index c157b5e5c9862..6a48b25b7eb63 100644
--- a/libcxx/test/benchmarks/algorithms/fill.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/fill.bench.cpp
@@ -12,40 +12,40 @@
 #include <benchmark/benchmark.h>
 #include <vector>
 
-static void bm_fill_n(benchmark::State& state) {
+static void bm_fill_n_vector_bool(benchmark::State& state) {
   std::vector<bool> vec1(state.range());
   for (auto _ : state) {
     benchmark::DoNotOptimize(vec1);
     benchmark::DoNotOptimize(std::fill_n(vec1.begin(), vec1.size(), false));
   }
 }
-BENCHMARK(bm_fill_n)->DenseRange(1, 8)->Range(16, 1 << 20);
+BENCHMARK(bm_fill_n_vector_bool)->DenseRange(1, 8)->Range(16, 1 << 20);
 
-static void bm_ranges_fill_n(benchmark::State& state) {
+static void bm_ranges_fill_n_vector_bool(benchmark::State& state) {
   std::vector<bool> vec1(state.range());
   for (auto _ : state) {
     benchmark::DoNotOptimize(vec1);
     benchmark::DoNotOptimize(std::ranges::fill_n(vec1.begin(), vec1.size(), false));
   }
 }
-BENCHMARK(bm_ranges_fill_n)->DenseRange(1, 8)->Range(16, 1 << 20);
+BENCHMARK(bm_ranges_fill_n_vector_bool)->DenseRange(1, 8)->Range(16, 1 << 20);
 
-static void bm_fill(benchmark::State& state) {
+static void bm_fill_vector_bool(benchmark::State& state) {
   std::vector<bool> vec1(state.range());
   for (auto _ : state) {
     benchmark::DoNotOptimize(vec1);
     std::fill(vec1.begin(), vec1.end(), false);
   }
 }
-BENCHMARK(bm_fill)->DenseRange(1, 8)->Range(16, 1 << 20);
+BENCHMARK(bm_fill_vector_bool)->DenseRange(1, 8)->Range(16, 1 << 20);
 
-static void bm_ranges_fill(benchmark::State& state) {
+static void bm_ranges_fill_vector_bool(benchmark::State& state) {
   std::vector<bool> vec1(state.range());
   for (auto _ : state) {
     benchmark::DoNotOptimize(vec1);
     benchmark::DoNotOptimize(std::ranges::fill(vec1, false));
   }
 }
-BENCHMARK(bm_ranges_fill)->DenseRange(1, 8)->Range(16, 1 << 20);
+BENCHMARK(bm_ranges_fill_vector_bool)->DenseRange(1, 8)->Range(16, 1 << 20);
 
 BENCHMARK_MAIN();
diff --git a/libcxx/test/benchmarks/algorithms/ranges_contains.bench.cpp b/libcxx/test/benchmarks/algorithms/ranges_contains.bench.cpp
index b98e17a00ef83..c9a10202c8cfc 100644
--- a/libcxx/test/benchmarks/algorithms/ranges_contains.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/ranges_contains.bench.cpp
@@ -15,7 +15,7 @@
 
 #include "test_iterators.h"
 
-static void bm_contains_char(benchmark::State& state) {
+static void bm_contains_vector_char(benchmark::State& state) {
   std::vector<char> a(state.range(), 'a');
 
   for (auto _ : state) {
@@ -24,9 +24,9 @@ static void bm_contains_char(benchmark::State& state) {
     benchmark::DoNotOptimize(std::ranges::contains(a.begin(), a.end(), 'B'));
   }
 }
-BENCHMARK(bm_contains_char)->RangeMultiplier(16)->Range(16, 16 << 20);
+BENCHMARK(bm_contains_vector_char)->RangeMultiplier(16)->Range(16, 16 << 20);
 
-static void bm_contains_int(benchmark::State& state) {
+static void bm_contains_vector_int(benchmark::State& state) {
   std::vector<int> a(state.range(), 1);
 
   for (auto _ : state) {
@@ -35,9 +35,9 @@ static void bm_contains_int(benchmark::State& state) {
     benchmark::DoNotOptimize(std::ranges::contains(a.begin(), a.end(), 2));
   }
 }
-BENCHMARK(bm_contains_int)->RangeMultiplier(16)->Range(16, 16 << 20);
+BENCHMARK(bm_contains_vector_int)->RangeMultiplier(16)->Range(16, 16 << 20);
 
-static void bm_contains_bool(benchmark::State& state) {
+static void bm_contains_vector_bool(benchmark::State& state) {
   std::vector<bool> a(state.range(), true);
 
   for (auto _ : state) {
@@ -46,6 +46,6 @@ static void bm_contains_bool(benchmark::State& state) {
     benchmark::DoNotOptimize(std::ranges::contains(a.begin(), a.end(), false));
   }
 }
-BENCHMARK(bm_contains_bool)->RangeMultiplier(16)->Range(16, 16 << 20);
+BENCHMARK(bm_contains_vector_bool)->RangeMultiplier(16)->Range(16, 16 << 20);
 
 BENCHMARK_MAIN();

Copy link
Member

@mordante mordante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM!

@ldionne ldionne merged commit a6093d3 into llvm:main Feb 15, 2025
78 checks passed
@ldionne ldionne deleted the review/benchmark-call-out-vector-bool branch February 15, 2025 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants