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

Function QueryMapWithInternedStrings

valdi/test/benchmark/string_benchmark.cpp:115–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113BENCHMARK(QueryMapWithRegularStrings)->Range(8, 512);
114
115static void QueryMapWithInternedStrings(benchmark::State& state) {
116 auto strings = makeRandomStrings(state.range(0));
117 auto& stringCache = StringCache::getGlobal();
118
119 auto cachedStrings = internStrings(stringCache, strings);
120 FlatMap<StringBox, bool> map;
121
122 for (const auto& str : cachedStrings) {
123 map[str] = true;
124 }
125
126 for (auto _ : state) {
127 for (const auto& str : cachedStrings) {
128 const auto& it = map.find(str);
129
130 benchmark::DoNotOptimize(it != map.end());
131 }
132 }
133}
134BENCHMARK(QueryMapWithInternedStrings)->Range(8, 512);
135
136BENCHMARK_MAIN();

Callers

nothing calls this directly

Calls 5

makeRandomStringsFunction · 0.85
getGlobalFunction · 0.85
internStringsFunction · 0.85
endMethod · 0.65
findMethod · 0.45

Tested by

no test coverage detected