MCPcopy Create free account
hub / github.com/apache/arrow / BenchmarkCacheLookups

Function BenchmarkCacheLookups

cpp/src/arrow/util/cache_benchmark.cc:57–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55
56template <typename Cache, typename Key, typename Value>
57static void BenchmarkCacheLookups(benchmark::State& state, const std::vector<Key>& keys,
58 const std::vector<Value>& values) {
59 const int32_t nitems = static_cast<int32_t>(keys.size());
60 Cache cache(nitems);
61 for (int32_t i = 0; i < nitems; ++i) {
62 cache.Replace(keys[i], values[i]);
63 }
64
65 for (auto _ : state) {
66 int64_t nfinds = 0;
67 for (const auto& key : keys) {
68 nfinds += (cache.Find(key) != nullptr);
69 }
70 benchmark::DoNotOptimize(nfinds);
71 ARROW_CHECK_EQ(nfinds, nitems);
72 }
73 state.SetItemsProcessed(state.iterations() * nitems);
74}
75
76static void LruCacheLookup(benchmark::State& state) {
77 const auto keys = MakeStrings(kCacheSize, state.range(0));

Callers

nothing calls this directly

Calls 3

sizeMethod · 0.45
ReplaceMethod · 0.45
FindMethod · 0.45

Tested by

no test coverage detected