| 60 | } |
| 61 | |
| 62 | static void BenchmarkUTF8Validation( |
| 63 | benchmark::State& state, // NOLINT non-const reference |
| 64 | const std::string& s, bool expected) { |
| 65 | auto data = reinterpret_cast<const uint8_t*>(s.data()); |
| 66 | auto data_size = static_cast<int64_t>(s.size()); |
| 67 | |
| 68 | InitializeUTF8(); |
| 69 | bool b = ValidateUTF8NoInline(data, data_size); |
| 70 | if (b != expected) { |
| 71 | std::cerr << "Unexpected validation result" << std::endl; |
| 72 | std::abort(); |
| 73 | } |
| 74 | |
| 75 | while (state.KeepRunning()) { |
| 76 | bool b = ValidateUTF8NoInline(data, data_size); |
| 77 | benchmark::DoNotOptimize(b); |
| 78 | } |
| 79 | state.SetBytesProcessed(state.iterations() * s.size()); |
| 80 | } |
| 81 | |
| 82 | static void BenchmarkASCIIValidation( |
| 83 | benchmark::State& state, // NOLINT non-const reference |
no test coverage detected