third_party/benchmark/src/string_util.h
Go to the documentation of this file.
1 #ifndef BENCHMARK_STRING_UTIL_H_
2 #define BENCHMARK_STRING_UTIL_H_
3 
4 #include <sstream>
5 #include <string>
6 #include <utility>
7 #include "internal_macros.h"
8 
9 namespace benchmark {
10 
11 void AppendHumanReadable(int n, std::string* str);
12 
13 std::string HumanReadableNumber(double n, double one_k = 1024.0);
14 
15 #if defined(__MINGW32__)
16 __attribute__((format(__MINGW_PRINTF_FORMAT, 1, 2)))
17 #elif defined(__GNUC__)
18 __attribute__((format(printf, 1, 2)))
19 #endif
21 StrFormat(const char* format, ...);
22 
23 inline std::ostream& StrCatImp(std::ostream& out) BENCHMARK_NOEXCEPT {
24  return out;
25 }
26 
27 template <class First, class... Rest>
28 inline std::ostream& StrCatImp(std::ostream& out, First&& f, Rest&&... rest) {
29  out << std::forward<First>(f);
30  return StrCatImp(out, std::forward<Rest>(rest)...);
31 }
32 
33 template <class... Args>
34 inline std::string StrCat(Args&&... args) {
35  std::ostringstream ss;
36  StrCatImp(ss, std::forward<Args>(args)...);
37  return ss.str();
38 }
39 
40 std::vector<std::string> StrSplit(const std::string& str, char delim);
41 
42 #ifdef BENCHMARK_STL_ANDROID_GNUSTL
43 /*
44  * GNU STL in Android NDK lacks support for some C++11 functions, including
45  * stoul, stoi, stod. We reimplement them here using C functions strtoul,
46  * strtol, strtod. Note that reimplemented functions are in benchmark::
47  * namespace, not std:: namespace.
48  */
49 unsigned long stoul(const std::string& str, size_t* pos = nullptr,
50  int base = 10);
51 int stoi(const std::string& str, size_t* pos = nullptr, int base = 10);
52 double stod(const std::string& str, size_t* pos = nullptr);
53 #else
54 using std::stoul;
55 using std::stoi;
56 using std::stod;
57 #endif
58 
59 } // end namespace benchmark
60 
61 #endif // BENCHMARK_STRING_UTIL_H_
xds_interop_client.str
str
Definition: xds_interop_client.py:487
gen_build_yaml.out
dictionary out
Definition: src/benchmark/gen_build_yaml.py:24
http2_test_server.format
format
Definition: http2_test_server.py:118
pos
int pos
Definition: libuv/docs/code/tty-gravity/main.c:11
benchmark
Definition: bm_alarm.cc:55
printf
_Use_decl_annotations_ int __cdecl printf(const char *_Format,...)
Definition: cs_driver.c:91
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
asyncio_get_stats.args
args
Definition: asyncio_get_stats.py:40
hpack_encoder_fixtures::Args
Args({0, 16384})
benchmark::HumanReadableNumber
std::string HumanReadableNumber(double n, double one_k)
Definition: benchmark/src/string_util.cc:121
__attribute__
__attribute__(void) start
BENCHMARK_NOEXCEPT
#define BENCHMARK_NOEXCEPT
Definition: benchmark/include/benchmark/benchmark.h:234
gen_synthetic_protos.base
base
Definition: gen_synthetic_protos.py:31
internal_macros.h
benchmark::StrSplit
std::vector< std::string > StrSplit(const std::string &str, char delim)
Definition: benchmark/src/string_util.cc:166
benchmark::StrCatImp
std::ostream & StrCatImp(std::ostream &out) BENCHMARK_NOEXCEPT
Definition: third_party/benchmark/src/string_util.h:23
benchmark::StrFormat
std::string StrFormat(const char *format,...)
Definition: benchmark/src/string_util.cc:158
benchmark::AppendHumanReadable
void AppendHumanReadable(int n, std::string *str)
Definition: benchmark/src/string_util.cc:114
benchmark::StrCat
std::string StrCat(Args &&... args)
Definition: third_party/benchmark/src/string_util.h:34


grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:21