[RISCV] Add shrinkwrap test cases showing gaps in current impl
[llvm-project.git] / third-party / benchmark / src / benchmark_name.cc
blob01676bbc84df4233780c9c2ead89d31e5a70a930
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.
15 #include <benchmark/benchmark.h>
17 namespace benchmark {
19 namespace {
21 // Compute the total size of a pack of std::strings
22 size_t size_impl() { return 0; }
24 template <typename Head, typename... Tail>
25 size_t size_impl(const Head& head, const Tail&... tail) {
26 return head.size() + size_impl(tail...);
29 // Join a pack of std::strings using a delimiter
30 // TODO: use absl::StrJoin
31 void join_impl(std::string&, char) {}
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;
40 s += head;
42 join_impl(s, delimiter, tail...);
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;
52 } // namespace
54 BENCHMARK_EXPORT
55 std::string BenchmarkName::str() const {
56 return join('/', function_name, args, min_time, min_warmup_time, iterations,
57 repetitions, time_type, threads);
59 } // namespace benchmark