diff options
author | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2015-04-15 21:44:52 -0700 |
---|---|---|
committer | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2015-04-15 21:44:52 -0700 |
commit | bb3aee447b698c7dcec6428a17c61e66dd43dfd6 (patch) | |
tree | 55d2efbec08ee116ae1131d51920b121b8a7d877 | |
parent | 8c8940430ac0d0f82add6fb028ffe9712c9669e8 (diff) |
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.
-rw-r--r-- | tests/allocator.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
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<void*>(align_to_page(reinterpret_cast<size_t>(result))); } void* allocate(size_t size) |