From bb3aee447b698c7dcec6428a17c61e66dd43dfd6 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Wed, 15 Apr 2015 21:44:52 -0700 Subject: tests: Use malloc for OSX/Linux page heap Switch to malloc and manually aligning the pointer to the page boundary. mmap is much slower than malloc; this change makes tests ~4x faster. --- tests/allocator.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests/allocator.cpp') diff --git a/tests/allocator.cpp b/tests/allocator.cpp index 8ca0963..a43e14a 100644 --- a/tests/allocator.cpp +++ b/tests/allocator.cpp @@ -80,7 +80,9 @@ namespace void* allocate_page_aligned(size_t size) { - return mmap(0, size + page_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); + void* result = malloc(size + page_size); + + return reinterpret_cast(align_to_page(reinterpret_cast(result))); } void* allocate(size_t size) -- cgit v1.2.3