Rename ArenaAllocator -> Arena

This commit is contained in:
2025-09-05 17:57:04 -04:00
parent 46fe51c0bb
commit f56ed2bfbe
22 changed files with 267 additions and 279 deletions

View File

@@ -0,0 +1,39 @@
#include "arena.hpp"
#include <nanobench.h>
#include <vector>
int main() {
// Small allocation benchmark - Arena vs malloc
for (int alloc_size : {16, 64, 256, 1024}) {
auto bench = ankerl::nanobench::Bench()
.title("Small Allocations (" + std::to_string(alloc_size) +
" bytes)")
.unit("allocation")
.warmup(100);
{
// Arena allocator benchmark
Arena arena;
bench.run("Arena", [&] {
void *ptr = arena.allocate_raw(alloc_size);
ankerl::nanobench::doNotOptimizeAway(ptr);
});
}
{
// Standard malloc benchmark
std::vector<void *> malloc_ptrs;
malloc_ptrs.reserve(1'000'000);
bench.run("malloc", [&] {
void *ptr = std::malloc(alloc_size);
malloc_ptrs.push_back(ptr);
});
for (void *ptr : malloc_ptrs) {
std::free(ptr);
}
}
}
return 0;
}