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

Function CreateFlatMapWithReserve

valdi/test/benchmark/map_benchmark.cpp:52–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50BENCHMARK(CreateUnorderedMapWithReserve)->DenseRange(8, 128, 8);
51
52static void CreateFlatMapWithReserve(benchmark::State& state) {
53 StringCache stringCache;
54 auto cachedStrings = makeRandomInternedStrings(stringCache, state.range(0), 10);
55
56 for (auto _ : state) {
57 Valdi::FlatMap<StringBox, bool> map;
58 map.reserve(cachedStrings.size());
59
60 for (const auto& str : cachedStrings) {
61 map[str] = true;
62 }
63 }
64}
65BENCHMARK(CreateFlatMapWithReserve)->DenseRange(8, 128, 8);
66
67static void QueryUnorderedMap(benchmark::State& state) {

Callers

nothing calls this directly

Calls 3

reserveMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected