15 #include "absl/strings/ascii.h"
22 #include "benchmark/benchmark.h"
26 std::array<unsigned char, 256> MakeShuffledBytes() {
27 std::array<unsigned char, 256>
bytes;
28 for (
size_t i = 0; i < 256; ++i) bytes[i] = static_cast<unsigned char>(
i);
29 std::random_device rd;
30 std::seed_seq
seed({rd(), rd(), rd(), rd(), rd(), rd(), rd(), rd()});
36 template <
typename Function>
38 std::array<unsigned char, 256>
bytes = MakeShuffledBytes();
50 using StdAsciiFunction =
int (*)(
int);
51 template <StdAsciiFunction f>
56 using AbslAsciiIsFunction =
bool (*)(
unsigned char);
57 template <AbslAsciiIsFunction f>
62 using AbslAsciiToFunction = char (*)(
unsigned char);
63 template <AbslAsciiToFunction f>
68 inline char Noop(
unsigned char b) {
return static_cast<char>(
b); }
109 BENCHMARK(BM_StrToLower)->Range(1, 1 << 20);
118 BENCHMARK(BM_StrToUpper)->Range(1, 1 << 20);