line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#include "test.h" |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
using namespace panda; |
4
|
|
|
|
|
|
|
|
5
|
0
|
|
|
|
|
|
struct Base { |
6
|
|
|
|
|
|
|
int x; |
7
|
2
|
50
|
|
|
|
|
virtual ~Base() {} |
8
|
|
|
|
|
|
|
}; |
9
|
|
|
|
|
|
|
|
10
|
0
|
0
|
|
|
|
|
struct Base1 : virtual Base { |
|
|
0
|
|
|
|
|
|
11
|
|
|
|
|
|
|
int a; |
12
|
|
|
|
|
|
|
}; |
13
|
|
|
|
|
|
|
|
14
|
0
|
0
|
|
|
|
|
struct Base2 : virtual Base1 { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
15
|
|
|
|
|
|
|
int b; |
16
|
|
|
|
|
|
|
}; |
17
|
|
|
|
|
|
|
|
18
|
0
|
0
|
|
|
|
|
struct Der : virtual Base2 { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
19
|
|
|
|
|
|
|
int c; |
20
|
|
|
|
|
|
|
}; |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
struct ABC { |
23
|
|
|
|
|
|
|
int ttt; |
24
|
0
|
0
|
|
|
|
|
virtual ~ABC() {} |
25
|
|
|
|
|
|
|
}; |
26
|
|
|
|
|
|
|
|
27
|
0
|
0
|
|
|
|
|
struct Epta : virtual Der, virtual ABC { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
28
|
|
|
|
|
|
|
int erc; |
29
|
|
|
|
|
|
|
}; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
struct Wrong { |
32
|
|
|
|
|
|
|
virtual ~Wrong() {} |
33
|
|
|
|
|
|
|
}; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
struct FastAlloc : AllocatedObject { |
36
|
|
|
|
|
|
|
int a; |
37
|
|
|
|
|
|
|
double b; |
38
|
|
|
|
|
|
|
uint64_t c; |
39
|
|
|
|
|
|
|
void* d; |
40
|
|
|
|
|
|
|
}; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
0
|
0
|
|
|
|
|
Base* get_suka () { return new Epta(); } |
44
|
|
|
|
|
|
|
|
45
|
18
|
|
|
|
|
|
TEST_CASE("dyn_cast", "[!benchmark]") { |
46
|
0
|
0
|
|
|
|
|
Base* b = get_suka(); |
47
|
0
|
|
|
|
|
|
uint64_t res = 0; |
48
|
0
|
0
|
|
|
|
|
BENCHMARK("dyn_cast") { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
49
|
0
|
0
|
|
|
|
|
for (size_t i = 0; i < 1000000000; i++) { |
50
|
0
|
0
|
|
|
|
|
res += (uint64_t)dyn_cast(b); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
0
|
0
|
|
|
|
|
WARN(res); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
18
|
|
|
|
|
|
TEST_CASE("bench_mempool_single", "[bench-mempool]") { |
57
|
0
|
0
|
|
|
|
|
MemoryPool pool(16); |
58
|
0
|
|
|
|
|
|
uint64_t res = 0; |
59
|
0
|
0
|
|
|
|
|
for (size_t i = 0; i < 1000000000; i++) { |
60
|
0
|
0
|
|
|
|
|
auto p = pool.allocate(); |
61
|
0
|
|
|
|
|
|
res += (uint64_t)p; |
62
|
0
|
|
|
|
|
|
pool.deallocate(p); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
} |
65
|
0
|
0
|
|
|
|
|
WARN(res); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
18
|
|
|
|
|
|
TEST_CASE("bench_mempool_multi", "[bench-mempool]") { |
69
|
0
|
0
|
|
|
|
|
MemoryPool pool(16); |
70
|
0
|
|
|
|
|
|
uint64_t res = 0; |
71
|
|
|
|
|
|
|
void* ptrs[1000]; |
72
|
0
|
0
|
|
|
|
|
for (size_t j = 0; j < 1000000; ++j) { |
73
|
0
|
0
|
|
|
|
|
for (size_t i = 0; i < 1000; ++i) { |
74
|
0
|
0
|
|
|
|
|
ptrs[i] = pool.allocate(); |
75
|
0
|
|
|
|
|
|
res += (uint64_t)ptrs[i]; |
76
|
|
|
|
|
|
|
} |
77
|
0
|
0
|
|
|
|
|
for (size_t i = 0; i < 1000; ++i) { |
78
|
0
|
|
|
|
|
|
pool.deallocate(ptrs[i]); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
0
|
0
|
|
|
|
|
WARN(res); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
18
|
|
|
|
|
|
TEST_CASE("bench_static_mempool_instance", "[bench-mempool]") { |
85
|
0
|
|
|
|
|
|
uint64_t res = 0; |
86
|
0
|
0
|
|
|
|
|
for (size_t i = 0; i < 1000000000; i++) { |
87
|
0
|
0
|
|
|
|
|
res += (uint64_t)StaticMemoryPool<16>::instance(); |
88
|
|
|
|
|
|
|
} |
89
|
0
|
0
|
|
|
|
|
WARN(res); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
18
|
|
|
|
|
|
TEST_CASE("bench_static_mempool_single", "[bench-mempool]") { |
93
|
0
|
|
|
|
|
|
uint64_t res = 0; |
94
|
0
|
0
|
|
|
|
|
for (size_t i = 0; i < 1000000000; i++) { |
95
|
0
|
0
|
|
|
|
|
auto p = StaticMemoryPool<16>::instance()->allocate(); |
|
|
0
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
res += (uint64_t)p; |
97
|
0
|
0
|
|
|
|
|
StaticMemoryPool<16>::instance()->deallocate(p); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
} |
100
|
0
|
0
|
|
|
|
|
WARN(res); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
18
|
|
|
|
|
|
TEST_CASE("bench_static_mempool_multi", "[bench-mempool]") { |
104
|
0
|
|
|
|
|
|
uint64_t res = 0; |
105
|
|
|
|
|
|
|
void* ptrs[1000]; |
106
|
0
|
0
|
|
|
|
|
for (size_t j = 0; j < 1000000; ++j) { |
107
|
0
|
0
|
|
|
|
|
for (size_t i = 0; i < 1000; ++i) { |
108
|
0
|
0
|
|
|
|
|
ptrs[i] = StaticMemoryPool<16>::allocate(); |
109
|
0
|
|
|
|
|
|
res += (uint64_t)ptrs[i]; |
110
|
|
|
|
|
|
|
} |
111
|
0
|
0
|
|
|
|
|
for (size_t i = 0; i < 1000; ++i) { |
112
|
0
|
0
|
|
|
|
|
StaticMemoryPool<16>::deallocate(ptrs[i]); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
} |
115
|
0
|
0
|
|
|
|
|
WARN(res); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
18
|
|
|
|
|
|
TEST_CASE("bench_dynamic_mempool_instance", "[bench-mempool]") { |
119
|
0
|
|
|
|
|
|
uint64_t res = 0; |
120
|
0
|
0
|
|
|
|
|
for (size_t i = 0; i < 1000000000; i++) { |
121
|
0
|
0
|
|
|
|
|
res += (uint64_t)DynamicMemoryPool::instance(); |
122
|
|
|
|
|
|
|
} |
123
|
0
|
0
|
|
|
|
|
WARN(res); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
124
|
0
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
18
|
|
|
|
|
|
TEST_CASE("bench_dynamic_mempool_single", "[bench-mempool]") { |
127
|
0
|
|
|
|
|
|
uint64_t res = 0; |
128
|
0
|
0
|
|
|
|
|
for (size_t i = 0; i < 1000000000; i++) { |
129
|
0
|
0
|
|
|
|
|
auto p = DynamicMemoryPool::instance()->allocate(16); |
|
|
0
|
|
|
|
|
|
130
|
0
|
|
|
|
|
|
res += (uint64_t)p; |
131
|
0
|
0
|
|
|
|
|
DynamicMemoryPool::instance()->deallocate(p, 16); |
|
|
0
|
|
|
|
|
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
} |
134
|
0
|
0
|
|
|
|
|
WARN(res); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
135
|
0
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
18
|
|
|
|
|
|
TEST_CASE("bench_pool_obj_single", "[bench-mempool]") { |
138
|
0
|
|
|
|
|
|
uint64_t res = 0; |
139
|
0
|
0
|
|
|
|
|
for (size_t i = 0; i < 1000000000; i++) { |
140
|
0
|
0
|
|
|
|
|
auto p = new FastAlloc(); |
141
|
0
|
|
|
|
|
|
res += (uint64_t)p; |
142
|
0
|
0
|
|
|
|
|
delete p; |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
} |
145
|
0
|
0
|
|
|
|
|
WARN(res); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
146
|
0
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
18
|
|
|
|
|
|
TEST_CASE("bench_pool_obj_multi", "[bench-mempool]") { |
149
|
0
|
|
|
|
|
|
uint64_t res = 0; |
150
|
|
|
|
|
|
|
FastAlloc* ptrs[1000]; |
151
|
0
|
0
|
|
|
|
|
for (size_t j = 0; j < 1000000; ++j) { |
152
|
0
|
0
|
|
|
|
|
for (size_t i = 0; i < 1000; ++i) { |
153
|
0
|
0
|
|
|
|
|
ptrs[i] = new FastAlloc(); |
154
|
0
|
|
|
|
|
|
res += (uint64_t)ptrs[i]; |
155
|
|
|
|
|
|
|
} |
156
|
0
|
0
|
|
|
|
|
for (size_t i = 0; i < 1000; ++i) { |
157
|
0
|
0
|
|
|
|
|
delete ptrs[i]; |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
} |
160
|
0
|
0
|
|
|
|
|
WARN(res); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
161
|
72
|
50
|
|
|
|
|
} |
|
|
50
|
|
|
|
|
|