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

Function TouchArea

cpp/src/arrow/memory_pool_benchmark.cc:65–78  ·  view source on GitHub ↗

Benchmark the cost of accessing always the same memory area. This gives us a lower bound of the potential difference between AllocateTouchDeallocate and AllocateDeallocate.

Source from the content-addressed store, hash-verified

63// This gives us a lower bound of the potential difference between
64// AllocateTouchDeallocate and AllocateDeallocate.
65static void TouchArea(benchmark::State& state) { // NOLINT non-const reference
66 const int64_t nbytes = state.range(0);
67 MemoryPool* pool = default_memory_pool();
68 uint8_t* data;
69 ARROW_CHECK_OK(pool->Allocate(nbytes, &data));
70
71 for (auto _ : state) {
72 TouchCacheLines(data, nbytes);
73 }
74
75 pool->Free(data, nbytes);
76 state.SetItemsProcessed(state.iterations());
77 state.SetBytesProcessed(state.iterations() * nbytes);
78}
79
80// Benchmark the raw cost of allocating memory.
81// Note this is a best case situation: we always allocate and deallocate exactly

Callers

nothing calls this directly

Calls 4

default_memory_poolFunction · 0.85
TouchCacheLinesFunction · 0.85
AllocateMethod · 0.45
FreeMethod · 0.45

Tested by

no test coverage detected