benchmark_name.cc
Go to the documentation of this file.
1 // Copyright 2015 Google Inc. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include <benchmark/benchmark.h>
16 
17 namespace benchmark {
18 
19 namespace {
20 
21 // Compute the total size of a pack of std::strings
22 size_t size_impl() { return 0; }
23 
24 template <typename Head, typename... Tail>
25 size_t size_impl(const Head& head, const Tail&... tail) {
26  return head.size() + size_impl(tail...);
27 }
28 
29 // Join a pack of std::strings using a delimiter
30 // TODO: use absl::StrJoin
31 void join_impl(std::string&, char) {}
32 
33 template <typename Head, typename... Tail>
34 void join_impl(std::string& s, const char delimiter, const Head& head,
35  const Tail&... tail) {
36  if (!s.empty() && !head.empty()) {
37  s += delimiter;
38  }
39 
40  s += head;
41 
42  join_impl(s, delimiter, tail...);
43 }
44 
45 template <typename... Ts>
46 std::string join(char delimiter, const Ts&... ts) {
47  std::string s;
48  s.reserve(sizeof...(Ts) + size_impl(ts...));
49  join_impl(s, delimiter, ts...);
50  return s;
51 }
52 } // namespace
53 
55  return join('/', function_name, args, min_time, iterations, repetitions,
57 }
58 } // namespace benchmark
benchmark::BenchmarkName::repetitions
std::string repetitions
Definition: benchmark/include/benchmark/benchmark.h:1398
benchmark::BenchmarkName::threads
std::string threads
Definition: benchmark/include/benchmark/benchmark.h:1400
benchmark
Definition: bm_alarm.cc:55
benchmark::BenchmarkName::str
std::string str() const
Definition: benchmark_name.cc:54
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
absl::FormatConversionChar::s
@ s
benchmark::BenchmarkName::iterations
std::string iterations
Definition: benchmark/include/benchmark/benchmark.h:1397
benchmark::BenchmarkName::min_time
std::string min_time
Definition: benchmark/include/benchmark/benchmark.h:1396
benchmark::BenchmarkName::function_name
std::string function_name
Definition: benchmark/include/benchmark/benchmark.h:1394
benchmark::BenchmarkName::time_type
std::string time_type
Definition: benchmark/include/benchmark/benchmark.h:1399
benchmark::BenchmarkName::args
std::string args
Definition: benchmark/include/benchmark/benchmark.h:1395


grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:46