27 using namespace folly;
33 constexpr
int kVstrSize = 16;
34 std::vector<std::string> vstr;
35 std::vector<StringPiece> vstrp;
38 void initStr(
int len) {
50 for (
int i = 0;
i < kVstrSize; ++
i) {
67 const size_t ffoDelimSize = 128;
68 vector<string> ffoDelim;
70 void initFile(
int len) {
71 std::uniform_int_distribution<uint32_t> validChar(1, 64);
74 char ch = validChar(rnd);
82 string generateString(
int len) {
83 std::uniform_int_distribution<uint32_t> validChar(1, 255);
86 ret.push_back(validChar(rnd));
91 void initDelims(
int len) {
94 string s(len - 1,
'\0');
98 for (
size_t i = 0;
i < ffoDelimSize; ++
i) {
101 auto n = rnd() % 8 + 1;
105 auto s_ = generateString(n);
108 s_[rnd() %
s_.size()] =
'a';
110 ffoDelim.push_back(
s_);
120 char x = haystack[0];
131 char x = haystack[0];
138 template <
class Func>
145 left.advance(p + 1)) {
152 template <
class Func>
157 char x = haystack[0];
282 const string delims32 =
"!bcdefghijklmnopqrstuvwxyz_012345";
307 "!bcdefghijklmnopqrstuvwxyz_" 308 "ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789$";
332 template <
class Func>
334 for (
size_t i = 0;
i < iters; ++
i) {
335 auto test =
i % ffoDelim.size();
336 auto p = func(ffoTestString, ffoDelim[
test]);
392 char x = haystack[0];
400 gflags::ParseCommandLineFlags(&argc, &argv,
true);
402 for (
int len : {1, 8, 10, 16, 32, 64, 128, 256, 10 * 1024, 1024 * 1024}) {
BENCHMARK_RELATIVE(FindSingleCharRange, n)
size_t qfind_first_byte_of_std(const StringPieceLite haystack, const StringPieceLite needles)
size_type find_first_of(const_range_type needles) const
size_type find(const_range_type str) const
size_t qfind_first_byte_of_byteset(const StringPieceLite haystack, const StringPieceLite needles)
void advance(size_type n)
constexpr size_type size() const
—— Concurrent Priority Queue Implementation ——
void findFirstOfRange(StringPiece needles, Func func, size_t n)
void countHits(Func func, size_t n)
#define FOR_EACH_RANGE(i, begin, end)
size_t qfind_first_byte_of(const StringPiece haystack, const StringPiece needles)
size_t qfind_first_byte_of_nosse(const StringPieceLite haystack, const StringPieceLite needles)
BENCHMARK(fbFollyGlobalBenchmarkBaseline)
static const size_type npos
size_t qfind_first_byte_of_bitset(const StringPieceLite haystack, const StringPieceLite needles)
void findFirstOfRandom(Func func, size_t iters)
auto doNotOptimizeAway(const T &datum) -> typename std::enable_if< !detail::DoNotOptimizeAwayNeedsIndirect< T >::value >::type
int main(int argc, char **argv)