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

Function CreateUnorderedMapWithReserve

valdi/test/benchmark/map_benchmark.cpp:37–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35BENCHMARK(CreateFlatMap)->DenseRange(8, 128, 8);
36
37static void CreateUnorderedMapWithReserve(benchmark::State& state) {
38 StringCache stringCache;
39 auto cachedStrings = makeRandomInternedStrings(stringCache, state.range(0), 10);
40
41 for (auto _ : state) {
42 std::unordered_map<StringBox, bool> map;
43 map.reserve(cachedStrings.size());
44
45 for (const auto& str : cachedStrings) {
46 map[str] = true;
47 }
48 }
49}
50BENCHMARK(CreateUnorderedMapWithReserve)->DenseRange(8, 128, 8);
51
52static void CreateFlatMapWithReserve(benchmark::State& state) {

Callers

nothing calls this directly

Calls 3

reserveMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected