Benchmark the cost of accessing always the same memory area. This gives us a lower bound of the potential difference between AllocateTouchDeallocate and AllocateDeallocate.
| 63 | // This gives us a lower bound of the potential difference between |
| 64 | // AllocateTouchDeallocate and AllocateDeallocate. |
| 65 | static 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 |
nothing calls this directly
no test coverage detected