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

Function IterateUnorderedMap

valdi/test/benchmark/map_benchmark.cpp:107–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105BENCHMARK(QueryFlatMap)->DenseRange(8, 128, 8);
106
107static void IterateUnorderedMap(benchmark::State& state) {
108 StringCache stringCache;
109 auto cachedStrings = makeRandomInternedStrings(stringCache, state.range(0), 10);
110
111 std::unordered_map<StringBox, bool> map;
112
113 for (const auto& str : cachedStrings) {
114 map[str] = true;
115 }
116
117 for (auto _ : state) {
118 for ([[maybe_unused]] const auto& it : map) {
119 benchmark::DoNotOptimize(it);
120 }
121 }
122}
123BENCHMARK(IterateUnorderedMap)->DenseRange(8, 128, 8);
124
125static void IterateFlatMap(benchmark::State& state) {

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected