-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_allocator.cpp
41 lines (34 loc) · 2.04 KB
/
test_allocator.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
30
31
32
33
34
35
36
37
38
39
40
41
//
// Created by Agustin Gianni ([email protected]) on 11/30/16.
//
#include <benchmark/benchmark.h>
#include "Allocator.h"
#include "DiskPool.h"
template <typename DISK_POOL_TYPE, template <typename> class THREADING_POLICY> void BM_ALLOC_IMPLICIT_POOL(benchmark::State &state) {
using CustomAllocator = Allocator<DISK_POOL_TYPE, THREADING_POLICY>;
while (state.KeepRunning()) {
auto mem = CustomAllocator::alloc(sizeof(size_t));
benchmark::DoNotOptimize(mem);
}
}
BENCHMARK_TEMPLATE(BM_ALLOC_IMPLICIT_POOL, DiskPoolAtomic, PerProcessPolicy)->ThreadRange(1, 16);
BENCHMARK_TEMPLATE(BM_ALLOC_IMPLICIT_POOL, DiskPoolLock, PerProcessPolicy)->ThreadRange(1, 16);
BENCHMARK_TEMPLATE(BM_ALLOC_IMPLICIT_POOL, DiskPoolSpinLock, PerProcessPolicy)->ThreadRange(1, 16);
BENCHMARK_TEMPLATE(BM_ALLOC_IMPLICIT_POOL, DiskPoolAtomic, PerThreadPolicy)->ThreadRange(1, 16);
BENCHMARK_TEMPLATE(BM_ALLOC_IMPLICIT_POOL, DiskPoolLock, PerThreadPolicy)->ThreadRange(1, 16);
BENCHMARK_TEMPLATE(BM_ALLOC_IMPLICIT_POOL, DiskPoolSpinLock, PerThreadPolicy)->ThreadRange(1, 16);
template <typename DISK_POOL_TYPE, template <typename> class THREADING_POLICY> void BM_ALLOC_EXPLICIT_POOL(benchmark::State &state) {
using CustomAllocator = Allocator<DISK_POOL_TYPE, THREADING_POLICY>;
auto &pool = CustomAllocator::instance();
while (state.KeepRunning()) {
auto mem = CustomAllocator::alloc(pool, sizeof(size_t));
benchmark::DoNotOptimize(mem);
}
}
BENCHMARK_TEMPLATE(BM_ALLOC_EXPLICIT_POOL, DiskPoolAtomic, PerProcessPolicy)->ThreadRange(1, 16);
BENCHMARK_TEMPLATE(BM_ALLOC_EXPLICIT_POOL, DiskPoolLock, PerProcessPolicy)->ThreadRange(1, 16);
BENCHMARK_TEMPLATE(BM_ALLOC_EXPLICIT_POOL, DiskPoolSpinLock, PerProcessPolicy)->ThreadRange(1, 16);
BENCHMARK_TEMPLATE(BM_ALLOC_EXPLICIT_POOL, DiskPoolAtomic, PerThreadPolicy)->ThreadRange(1, 16);
BENCHMARK_TEMPLATE(BM_ALLOC_EXPLICIT_POOL, DiskPoolLock, PerThreadPolicy)->ThreadRange(1, 16);
BENCHMARK_TEMPLATE(BM_ALLOC_EXPLICIT_POOL, DiskPoolSpinLock, PerThreadPolicy)->ThreadRange(1, 16);
BENCHMARK_MAIN()