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