diff options
author | Abseil Team <absl-team@google.com> | 2023-10-23 17:02:31 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-10-23 17:03:27 -0700 |
commit | a6d9a9cddade9139616a980c8092431492b84f3c (patch) | |
tree | 70a07d57303c04a8ff01936310026c28caee6b74 /absl/strings/ascii_benchmark.cc | |
parent | a0b72adc3576eb0b77efb7133207c354d0adb4bc (diff) |
Performance improvements for `absl::AsciiStrToLower` and `absl::AsciiStrToUpper`.
PiperOrigin-RevId: 575969640
Change-Id: If6ddc0a71debfe571c2739ec91fc99594bc36f88
Diffstat (limited to 'absl/strings/ascii_benchmark.cc')
-rw-r--r-- | absl/strings/ascii_benchmark.cc | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/absl/strings/ascii_benchmark.cc b/absl/strings/ascii_benchmark.cc index b04b28ca..3aecdb8b 100644 --- a/absl/strings/ascii_benchmark.cc +++ b/absl/strings/ascii_benchmark.cc @@ -105,18 +105,28 @@ static void BM_StrToLower(benchmark::State& state) { const int size = state.range(0); std::string s(size, 'X'); for (auto _ : state) { - benchmark::DoNotOptimize(absl::AsciiStrToLower(s)); + benchmark::DoNotOptimize(s); + std::string res = absl::AsciiStrToLower(s); + benchmark::DoNotOptimize(res); } } -BENCHMARK(BM_StrToLower)->Range(1, 1 << 20); +BENCHMARK(BM_StrToLower) + ->DenseRange(0, 32) + ->RangeMultiplier(2) + ->Range(64, 1 << 20); static void BM_StrToUpper(benchmark::State& state) { const int size = state.range(0); std::string s(size, 'x'); for (auto _ : state) { - benchmark::DoNotOptimize(absl::AsciiStrToUpper(s)); + benchmark::DoNotOptimize(s); + std::string res = absl::AsciiStrToUpper(s); + benchmark::DoNotOptimize(res); } } -BENCHMARK(BM_StrToUpper)->Range(1, 1 << 20); +BENCHMARK(BM_StrToUpper) + ->DenseRange(0, 32) + ->RangeMultiplier(2) + ->Range(64, 1 << 20); } // namespace |