From cbfe51b2c01da330ff292b145de91346a5950163 Mon Sep 17 00:00:00 2001 From: Valery Mironov <32071355+MBkkt@users.noreply.github.com> Date: Wed, 15 May 2024 09:55:15 -0700 Subject: PR #1672: Optimize StrJoin with tuple without user defined formatter Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1672 https://github.com/abseil/abseil-cpp/discussions/1671 Merge ddcbb2466b2c9c4048d60be7e58cf47f935c257d into eba8db7baf6c326870f28e58977075b7b2fb243d Merging this change closes #1672 COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1672 from MBkkt:optimize-str-join ddcbb2466b2c9c4048d60be7e58cf47f935c257d PiperOrigin-RevId: 633988391 Change-Id: I2b3904211a29de3a768fb90a7fc106d7ff6c03e7 --- absl/strings/str_join_benchmark.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'absl/strings/str_join_benchmark.cc') diff --git a/absl/strings/str_join_benchmark.cc b/absl/strings/str_join_benchmark.cc index d6f689ff..be7a7257 100644 --- a/absl/strings/str_join_benchmark.cc +++ b/absl/strings/str_join_benchmark.cc @@ -16,6 +16,7 @@ #include "absl/strings/str_join.h" #include +#include #include #include @@ -94,4 +95,13 @@ BENCHMARK(BM_JoinStreamable) ->ArgPair(16, 256) ->ArgPair(256, 256); +void BM_JoinTuple(benchmark::State& state) { + for (auto _ : state) { + std::string s = + absl::StrJoin(std::make_tuple(123456789, 987654321, 24680, 13579), "/"); + benchmark::DoNotOptimize(s); + } +} +BENCHMARK(BM_JoinTuple); + } // namespace -- cgit v1.2.3