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

Function InternedStringComparison

valdi/test/benchmark/string_benchmark.cpp:51–64  ·  view source on GitHub ↗

How long does it take to compare StringBox objects

Source from the content-addressed store, hash-verified

49
50// How long does it take to compare StringBox objects
51static void InternedStringComparison(benchmark::State& state) {
52 auto strings = makeRandomStrings(state.range(0));
53 auto& stringCache = StringCache::getGlobal();
54
55 auto cachedStrings = internStrings(stringCache, strings);
56
57 for (auto _ : state) {
58 for (const auto& str : cachedStrings) {
59 for (const auto& other : cachedStrings) {
60 benchmark::DoNotOptimize(str == other);
61 }
62 }
63 }
64}
65BENCHMARK(InternedStringComparison)->Range(8, 512);
66
67static void CreateMapWithRegularStrings(benchmark::State& state) {

Callers

nothing calls this directly

Calls 3

makeRandomStringsFunction · 0.85
getGlobalFunction · 0.85
internStringsFunction · 0.85

Tested by

no test coverage detected