MCPcopy Create free account
hub / github.com/Snapchat/Valdi / QueryMapWithRegularStrings

Function QueryMapWithRegularStrings

valdi/test/benchmark/string_benchmark.cpp:97–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95BENCHMARK(CreateMapWithInternedStrings)->Range(8, 512);
96
97static void QueryMapWithRegularStrings(benchmark::State& state) {
98 auto strings = makeRandomStrings(state.range(0));
99 FlatMap<std::string, bool> map;
100
101 for (const auto& str : strings) {
102 map[str] = true;
103 }
104
105 for (auto _ : state) {
106 for (const auto& str : strings) {
107 const auto& it = map.find(str);
108
109 benchmark::DoNotOptimize(it != map.end());
110 }
111 }
112}
113BENCHMARK(QueryMapWithRegularStrings)->Range(8, 512);
114
115static void QueryMapWithInternedStrings(benchmark::State& state) {

Callers

nothing calls this directly

Calls 3

makeRandomStringsFunction · 0.85
endMethod · 0.65
findMethod · 0.45

Tested by

no test coverage detected