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 From 70a78b2fa5553931cb8e90457440f671ca1afc06 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Wed, 15 Apr 2015 22:11:13 -0700 Subject: tests: Fix Linux build --- tests/allocator.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'tests/allocator.cpp') diff --git a/tests/allocator.cpp b/tests/allocator.cpp index a43e14a..e1d99d5 100644 --- a/tests/allocator.cpp +++ b/tests/allocator.cpp @@ -2,6 +2,7 @@ #include #include +#include // Low-level allocation functions #if defined(_WIN32) || defined(_WIN64) @@ -113,8 +114,6 @@ namespace } } #else -# include - namespace { void* allocate(size_t size) -- cgit v1.2.3