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

Function QueryUnorderedMap

valdi/test/benchmark/map_benchmark.cpp:67–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65BENCHMARK(CreateFlatMapWithReserve)->DenseRange(8, 128, 8);
66
67static void QueryUnorderedMap(benchmark::State& state) {
68 StringCache stringCache;
69 auto cachedStrings = makeRandomInternedStrings(stringCache, state.range(0), 10);
70
71 std::unordered_map<StringBox, bool> map;
72
73 for (const auto& str : cachedStrings) {
74 map[str] = true;
75 }
76
77 for (auto _ : state) {
78 for (const auto& str : cachedStrings) {
79 const auto& it = map.find(str);
80
81 benchmark::DoNotOptimize(it != map.end());
82 }
83 }
84}
85BENCHMARK(QueryUnorderedMap)->DenseRange(8, 128, 8);
86
87static void QueryFlatMap(benchmark::State& state) {

Callers

nothing calls this directly

Calls 3

endMethod · 0.65
findMethod · 0.45

Tested by

no test coverage detected