-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathall_allocators.cpp
executable file
·29 lines (24 loc) · 1.14 KB
/
all_allocators.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>
#include <vector>
#include "bench.hpp"
// Allocators
#include <memory>
#include "allocators/aggressive_allocator.hpp"
#include "allocators/static_allocator.hpp"
#include "allocators/global_static_allocator.hpp"
int main(void) {
constexpr std::size_t n = 100'000;
constexpr std::size_t count = 10'000;
using T = int;
bench_print( std::span<const double>{bench<T, std::allocator<T>> (n, count)}, "std::allocator<int>" );
bench_print( std::span<const double>{bench<T, aggressive_allocator<T, 4*16384>> (n, count)},
"aggressive_allocator<int, 65,536>" );
bench_print( std::span<const double>{bench<T, static_allocator<T, 1LL<<25>> (n, count)},
"static_allocator<int, 32MB>");
/*
* Note for global_static_allocator: we are allocating in total n * count integers.
* Since we are doing no cleanup of memory allocated then it happens to allocate a bit too much.
* I have reduced count while keeping N the same for a fair comparison. */
bench_print( std::span<const double>{bench<T, global_static_allocator<T>> (n, 100)},
"global_static_allocator<int> (256MB)");
}