}
}
-
string generateString(int len) {
- std::uniform_int_distribution<uint32_t> validChar(1, 255); // no null-char
+ std::uniform_int_distribution<uint32_t> validChar(1, 255); // no null-char
string ret;
while (len--) {
ret.push_back(validChar(rnd));
void initDelims(int len) {
ffoDelim.clear();
- string s(len - 1, '\0'); // find_first_of won't finish until last char
+ string s(len - 1, '\0'); // find_first_of won't finish until last char
s.push_back('a');
ffoTestString = s;
auto s = generateString(n);
if (rnd() % 2) {
// ~half of tests will find a hit
- s[rnd() % s.size()] = 'a'; // yes, this could mean 'a' is a duplicate
+ s[rnd() % s.size()] = 'a'; // yes, this could mean 'a' is a duplicate
}
ffoDelim.push_back(s);
}
}
-} // anonymous namespace
+} // namespace
BENCHMARK(FindSingleCharMemchr, n) {
StringPiece haystack(str);
BENCHMARK_DRAW_LINE();
-const string delims64 = "!bcdefghijklmnopqrstuvwxyz_"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789$";
+const string delims64 =
+ "!bcdefghijklmnopqrstuvwxyz_"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789$";
BENCHMARK(FindFirstOf64NeedlesBase, n) {
findFirstOfRange(delims64, detail::qfind_first_byte_of, n);
int main(int argc, char** argv) {
gflags::ParseCommandLineFlags(&argc, &argv, true);
- for (int len : {1, 8, 10, 16, 32, 64, 128, 256, 10*1024, 1024*1024}) {
+ for (int len : {1, 8, 10, 16, 32, 64, 128, 256, 10 * 1024, 1024 * 1024}) {
initStr(len);
initDelims(len);
initFile(len);