| 78 | } |
| 79 | |
| 80 | static void BenchmarkStringHashing(benchmark::State& state, // NOLINT non-const reference |
| 81 | const std::vector<std::string>& values) { |
| 82 | uint64_t total_size = 0; |
| 83 | for (const std::string& v : values) { |
| 84 | total_size += v.size(); |
| 85 | } |
| 86 | |
| 87 | while (state.KeepRunning()) { |
| 88 | hash_t total = 0; |
| 89 | for (const std::string& v : values) { |
| 90 | total += ComputeStringHash<0>(v.data(), static_cast<int64_t>(v.size())); |
| 91 | total += ComputeStringHash<1>(v.data(), static_cast<int64_t>(v.size())); |
| 92 | } |
| 93 | benchmark::DoNotOptimize(total); |
| 94 | } |
| 95 | state.SetBytesProcessed(2 * state.iterations() * total_size); |
| 96 | state.SetItemsProcessed(2 * state.iterations() * values.size()); |
| 97 | } |
| 98 | |
| 99 | static void HashSmallStrings(benchmark::State& state) { // NOLINT non-const reference |
| 100 | const std::vector<std::string> values = MakeStrings(10000, 2, 20); |
no test coverage detected