#include <folly/String.h>
#include <boost/algorithm/string.hpp>
#include <folly/Benchmark.h>
#include <folly/Random.h>
#include <random>
Go to the source code of this file.
|
| | BENCHMARK (libc_tolower, iters) |
| |
| | BENCHMARK (folly_toLowerAscii, iters) |
| |
| void | stringPrintfOutputSize (int iters, int param) |
| |
| | BENCHMARK (stringPrintfAppendfBenchmark, iters) |
| |
| | BENCHMARK (splitOnSingleChar, iters) |
| |
| | BENCHMARK (splitOnSingleCharFixed, iters) |
| |
| | BENCHMARK (splitOnSingleCharFixedAllowExtra, iters) |
| |
| | BENCHMARK (splitStr, iters) |
| |
| | BENCHMARK (splitStrFixed, iters) |
| |
| | BENCHMARK (boost_splitOnSingleChar, iters) |
| |
| | BENCHMARK (joinCharStr, iters) |
| |
| | BENCHMARK (joinStrStr, iters) |
| |
| | BENCHMARK (joinInt, iters) |
| |
| int | main (int argc, char **argv) |
| |
| BENCHMARK |
( |
libc_tolower |
, |
|
|
iters |
|
|
) |
| |
Definition at line 27 of file StringBenchmark.cpp.
References i.
28 static const size_t kSize = 256;
35 static char input[kSize];
36 for (
size_t i = 0;
i < kSize;
i++) {
37 input[
i] = (char)(
i & 0xff);
39 for (
auto i = iters;
i > 0;
i--) {
40 for (
size_t offset = 0; offset < kSize; offset++) {
41 input[offset] = tolower(input[offset]);
| BENCHMARK |
( |
folly_toLowerAscii |
, |
|
|
iters |
|
|
) |
| |
Definition at line 46 of file StringBenchmark.cpp.
References i, and folly::toLowerAscii().
47 static const size_t kSize = 256;
48 static char input[kSize];
49 for (
size_t i = 0;
i < kSize;
i++) {
50 input[
i] = (char)(
i & 0xff);
52 for (
auto i = iters;
i > 0;
i--) {
void toLowerAscii(char *str, size_t length)
| BENCHMARK |
( |
stringPrintfAppendfBenchmark |
, |
|
|
iters |
|
|
) |
| |
Definition at line 82 of file StringBenchmark.cpp.
References folly::BENCHMARK(), BENCHMARK_SUSPEND, c, folly::doNotOptimizeAway(), encode(), folly::hexlify(), i, folly::gen::detail::passthrough(), folly::basic_fbstring< E, T, A, Storage >::push_back(), folly::basic_fbstring< E, T, A, Storage >::reserve(), folly::basic_fbstring< E, T, A, Storage >::resize(), s, folly::Random::secureRandom(), folly::Range< Iter >::size(), folly::basic_fbstring< E, T, A, Storage >::size(), string, folly::stringAppendf(), folly::Range< Iter >::subpiece(), uint32_t, and folly::unhexlify().
83 for (
unsigned int i = 0;
i < iters; ++
i) {
88 for (
int j = 0; j < 300000; ++j) {
#define BENCHMARK_SUSPEND
std::string & stringAppendf(std::string *output, const char *format,...)
| BENCHMARK |
( |
splitOnSingleChar |
, |
|
|
iters |
|
|
) |
| |
Definition at line 207 of file StringBenchmark.cpp.
References i, folly::split(), and string.
208 static const std::string line =
"one:two:three:four";
209 for (
size_t i = 0;
i < iters << 4; ++
i) {
210 std::vector<StringPiece> pieces;
void split(const Delim &delimiter, const String &input, std::vector< OutputType > &out, bool ignoreEmpty)
| BENCHMARK |
( |
splitOnSingleCharFixed |
, |
|
|
iters |
|
|
) |
| |
Definition at line 215 of file StringBenchmark.cpp.
References a, b, c, i, folly::split(), and string.
216 static const std::string line =
"one:two:three:four";
217 for (
size_t i = 0;
i < iters << 4; ++
i) {
void split(const Delim &delimiter, const String &input, std::vector< OutputType > &out, bool ignoreEmpty)
| BENCHMARK |
( |
splitOnSingleCharFixedAllowExtra |
, |
|
|
iters |
|
|
) |
| |
| BENCHMARK |
( |
splitStr |
, |
|
|
iters |
|
|
) |
| |
Definition at line 231 of file StringBenchmark.cpp.
References i, folly::split(), and string.
232 static const std::string line =
"one-*-two-*-three-*-four";
233 for (
size_t i = 0;
i < iters << 4; ++
i) {
234 std::vector<StringPiece> pieces;
void split(const Delim &delimiter, const String &input, std::vector< OutputType > &out, bool ignoreEmpty)
| BENCHMARK |
( |
splitStrFixed |
, |
|
|
iters |
|
|
) |
| |
Definition at line 239 of file StringBenchmark.cpp.
References a, b, c, i, folly::split(), and string.
240 static const std::string line =
"one-*-two-*-three-*-four";
241 for (
size_t i = 0;
i < iters << 4; ++
i) {
void split(const Delim &delimiter, const String &input, std::vector< OutputType > &out, bool ignoreEmpty)
| BENCHMARK |
( |
boost_splitOnSingleChar |
, |
|
|
iters |
|
|
) |
| |
Definition at line 247 of file StringBenchmark.cpp.
References c, i, folly::gen::split(), and string.
248 static const std::string line =
"one:two:three:four";
249 bool (*pred)(char) = [](
char c) ->
bool {
return c ==
':'; };
250 for (
size_t i = 0;
i < iters << 4; ++
i) {
251 std::vector<boost::iterator_range<std::string::const_iterator>> pieces;
S split(const StringPiece source, char delimiter)
| BENCHMARK |
( |
joinCharStr |
, |
|
|
iters |
|
|
) |
| |
Definition at line 256 of file StringBenchmark.cpp.
References i, folly::join(), gmock_output_test::output, and string.
257 static const std::vector<std::string> input = {
258 "one",
"two",
"three",
"four",
"five",
"six",
"seven"};
259 for (
size_t i = 0;
i < iters << 4; ++
i) {
void join(const Delim &delimiter, Iterator begin, Iterator end, String &output)
| BENCHMARK |
( |
joinStrStr |
, |
|
|
iters |
|
|
) |
| |
Definition at line 265 of file StringBenchmark.cpp.
References i, folly::join(), gmock_output_test::output, and string.
266 static const std::vector<std::string> input = {
267 "one",
"two",
"three",
"four",
"five",
"six",
"seven"};
268 for (
size_t i = 0;
i < iters << 4; ++
i) {
void join(const Delim &delimiter, Iterator begin, Iterator end, String &output)
| BENCHMARK |
( |
joinInt |
, |
|
|
iters |
|
|
) |
| |
Definition at line 274 of file StringBenchmark.cpp.
References i, folly::join(), gmock_output_test::output, and string.
275 static const auto input = {123, 456, 78910, 1112, 1314, 151, 61718};
276 for (
size_t i = 0;
i < iters << 4; ++
i) {
void join(const Delim &delimiter, Iterator begin, Iterator end, String &output)
| int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
| void stringPrintfOutputSize |
( |
int |
iters, |
|
|
int |
param |
|
) |
| |
Definition at line 59 of file StringBenchmark.cpp.
References BENCHMARK_PARAM, BENCHMARK_SUSPEND, buffer(), i, int64_t, s, and folly::stringPrintf().
62 buffer.resize(param,
'x');
66 string s =
stringPrintf(
"msg: %d, %d, %s", 10, 20, buffer.c_str());
std::vector< uint8_t > buffer(kBufferSize+16)
#define BENCHMARK_SUSPEND
std::string stringPrintf(const char *format,...)