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

Function CreateMapWithInternedStrings

valdi/test/benchmark/string_benchmark.cpp:80–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78BENCHMARK(CreateMapWithRegularStrings)->Range(8, 512);
79
80static void CreateMapWithInternedStrings(benchmark::State& state) {
81 auto strings = makeRandomStrings(state.range(0));
82 auto& stringCache = StringCache::getGlobal();
83
84 auto cachedStrings = internStrings(stringCache, strings);
85
86 for (auto _ : state) {
87 FlatMap<StringBox, bool> map;
88 map.reserve(cachedStrings.size());
89
90 for (const auto& str : cachedStrings) {
91 map[str] = true;
92 }
93 }
94}
95BENCHMARK(CreateMapWithInternedStrings)->Range(8, 512);
96
97static void QueryMapWithRegularStrings(benchmark::State& state) {

Callers

nothing calls this directly

Calls 5

makeRandomStringsFunction · 0.85
getGlobalFunction · 0.85
internStringsFunction · 0.85
reserveMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected