30
30
// The exact meaning of each argument depends on the benchmark, allocator, and size components used.
31
31
// Refer to the 'argsName()' function in each component to find detailed descriptions of these arguments.
32
32
33
- static void default_alloc_fix_size(benchmark::internal::Benchmark *benchmark) {
34
- benchmark->Args ({10000 , 0 , 4096 });
35
- benchmark->Args ({10000 , 100000 , 4096 });
33
+ static void multithreaded(benchmark::internal::Benchmark *benchmark) {
36
34
benchmark->Threads (4 );
37
35
benchmark->Threads (1 );
38
36
}
39
37
40
- static void
41
- default_alloc_uniform_size (benchmark::internal::Benchmark *benchmark) {
42
- benchmark->Args ({10000 , 0 , 8 , 64 * 1024 , 8 });
43
- benchmark->Threads (4 );
44
- benchmark->Threads (1 );
45
- }
46
-
47
- UMF_BENCHMARK_TEMPLATE_DEFINE (alloc_benchmark, glibc_fix, fixed_alloc_size,
48
- glibc_malloc);
49
-
50
- UMF_BENCHMARK_REGISTER_F (alloc_benchmark, glibc_fix)
51
- ->Apply(&default_alloc_fix_size);
52
-
53
- UMF_BENCHMARK_TEMPLATE_DEFINE (alloc_benchmark, glibc_uniform,
54
- uniform_alloc_size, glibc_malloc);
55
- UMF_BENCHMARK_REGISTER_F (alloc_benchmark, glibc_uniform)
56
- ->Apply(&default_alloc_uniform_size);
57
-
58
- UMF_BENCHMARK_TEMPLATE_DEFINE (alloc_benchmark, os_provider, fixed_alloc_size,
59
- provider_allocator<os_provider>);
60
- UMF_BENCHMARK_REGISTER_F (alloc_benchmark, os_provider)
61
- ->Apply(&default_alloc_fix_size);
62
-
63
- UMF_BENCHMARK_TEMPLATE_DEFINE (alloc_benchmark, proxy_pool, fixed_alloc_size,
64
- pool_allocator<proxy_pool<os_provider>>);
65
-
66
- UMF_BENCHMARK_REGISTER_F (alloc_benchmark, proxy_pool)
67
- ->Apply(&default_alloc_fix_size);
68
-
69
- UMF_BENCHMARK_TEMPLATE_DEFINE (alloc_benchmark, disjoint_pool_fix,
70
- fixed_alloc_size,
71
- pool_allocator<disjoint_pool<os_provider>>);
72
- UMF_BENCHMARK_REGISTER_F (alloc_benchmark, disjoint_pool_fix)
73
- ->Apply(&default_alloc_fix_size);
74
-
75
- // TODO: debug why this crashes
76
- /* UMF_BENCHMARK_TEMPLATE_DEFINE(alloc_benchmark, disjoint_pool_uniform,
77
- uniform_alloc_size,
78
- pool_allocator<disjoint_pool<os_provider>>);
79
- UMF_BENCHMARK_REGISTER_F(alloc_benchmark, disjoint_pool_uniform)
80
- ->Apply(&default_alloc_uniform_size);
81
- */
82
-
83
- #ifdef UMF_POOL_JEMALLOC_ENABLED
84
- UMF_BENCHMARK_TEMPLATE_DEFINE (alloc_benchmark, jemalloc_pool_fix,
85
- fixed_alloc_size,
86
- pool_allocator<jemalloc_pool<os_provider>>);
87
- UMF_BENCHMARK_REGISTER_F (alloc_benchmark, jemalloc_pool_fix)
88
- ->Apply(&default_alloc_fix_size);
89
-
90
- UMF_BENCHMARK_TEMPLATE_DEFINE (alloc_benchmark, jemalloc_pool_uniform,
91
- uniform_alloc_size,
92
- pool_allocator<jemalloc_pool<os_provider>>);
93
- UMF_BENCHMARK_REGISTER_F (alloc_benchmark, jemalloc_pool_uniform)
94
- ->Apply(&default_alloc_uniform_size);
95
-
96
- #endif
97
- #ifdef UMF_POOL_SCALABLE_ENABLED
98
- UMF_BENCHMARK_TEMPLATE_DEFINE (alloc_benchmark, scalable_pool_fix,
99
- fixed_alloc_size,
100
- pool_allocator<scalable_pool<os_provider>>);
101
-
102
- UMF_BENCHMARK_REGISTER_F (alloc_benchmark, scalable_pool_fix)
103
- ->Apply(&default_alloc_fix_size);
104
-
105
- UMF_BENCHMARK_TEMPLATE_DEFINE (alloc_benchmark, scalable_pool_uniform,
106
- uniform_alloc_size,
107
- pool_allocator<scalable_pool<os_provider>>);
108
-
109
- UMF_BENCHMARK_REGISTER_F (alloc_benchmark, scalable_pool_uniform)
110
- ->Apply(&default_alloc_uniform_size);
111
- #endif
112
- // Multiple allocs/free
113
38
static void
114
39
default_multiple_alloc_fix_size (benchmark::internal::Benchmark *benchmark) {
115
- benchmark->Args ({10000 , 4096 });
116
- benchmark->Threads (4 );
117
- benchmark->Threads (1 );
40
+ benchmark->Args ({10000 , 1 , 4096 });
41
+ benchmark->Iterations (500000 );
118
42
}
119
43
120
44
static void
121
45
default_multiple_alloc_uniform_size (benchmark::internal::Benchmark *benchmark) {
122
- benchmark->Args ({10000 , 8 , 64 * 1024 , 8 });
123
- benchmark->Threads ( 4 );
124
- benchmark->Threads ( 1 );
46
+ benchmark->Args ({10000 , 1 , 8 , 4096 , 8 });
47
+ benchmark->Args ({ 10000 , 1 , 8 , 128 , 8 } );
48
+ benchmark->Iterations ( 500000 );
125
49
}
126
50
127
51
UMF_BENCHMARK_TEMPLATE_DEFINE (multiple_malloc_free_benchmark, glibc_fix,
128
52
fixed_alloc_size, glibc_malloc);
129
53
130
54
UMF_BENCHMARK_REGISTER_F (multiple_malloc_free_benchmark, glibc_fix)
131
- ->Apply(&default_multiple_alloc_fix_size);
55
+ ->Apply(&default_multiple_alloc_fix_size)
56
+ ->Apply(&multithreaded);
132
57
133
58
UMF_BENCHMARK_TEMPLATE_DEFINE (multiple_malloc_free_benchmark, glibc_uniform,
134
59
uniform_alloc_size, glibc_malloc);
135
60
UMF_BENCHMARK_REGISTER_F (multiple_malloc_free_benchmark, glibc_uniform)
136
- ->Apply(&default_multiple_alloc_uniform_size);
61
+ ->Apply(&default_multiple_alloc_uniform_size)
62
+ ->Apply(&multithreaded);
137
63
138
64
UMF_BENCHMARK_TEMPLATE_DEFINE (multiple_malloc_free_benchmark, proxy_pool,
139
65
fixed_alloc_size,
140
66
pool_allocator<proxy_pool<os_provider>>);
141
67
142
68
UMF_BENCHMARK_REGISTER_F (multiple_malloc_free_benchmark, proxy_pool)
143
- ->Apply(&default_multiple_alloc_fix_size);
69
+ ->Apply(&default_multiple_alloc_fix_size)
70
+ // reduce iterations, as this benchmark is slower than others
71
+ ->Iterations(50000 );
144
72
145
73
UMF_BENCHMARK_TEMPLATE_DEFINE (multiple_malloc_free_benchmark, os_provider,
146
74
fixed_alloc_size,
147
75
provider_allocator<os_provider>);
148
76
UMF_BENCHMARK_REGISTER_F (multiple_malloc_free_benchmark, os_provider)
149
- ->Apply(&default_multiple_alloc_fix_size);
77
+ ->Apply(&default_multiple_alloc_fix_size)
78
+ // reduce iterations, as this benchmark is slower than others
79
+ ->Iterations(50000 );
150
80
151
81
UMF_BENCHMARK_TEMPLATE_DEFINE (multiple_malloc_free_benchmark, disjoint_pool_fix,
152
82
fixed_alloc_size,
153
83
pool_allocator<disjoint_pool<os_provider>>);
154
84
UMF_BENCHMARK_REGISTER_F (multiple_malloc_free_benchmark, disjoint_pool_fix)
155
- ->Apply(&default_multiple_alloc_fix_size);
85
+ ->Apply(&default_multiple_alloc_fix_size)
86
+ ->Apply(&multithreaded);
156
87
157
88
UMF_BENCHMARK_TEMPLATE_DEFINE (multiple_malloc_free_benchmark,
158
89
disjoint_pool_uniform, uniform_alloc_size,
@@ -165,13 +96,15 @@ UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark, jemalloc_pool_fix,
165
96
fixed_alloc_size,
166
97
pool_allocator<jemalloc_pool<os_provider>>);
167
98
UMF_BENCHMARK_REGISTER_F (multiple_malloc_free_benchmark, jemalloc_pool_fix)
168
- ->Apply(&default_multiple_alloc_fix_size);
99
+ ->Apply(&default_multiple_alloc_fix_size)
100
+ ->Apply(&multithreaded);
169
101
170
102
UMF_BENCHMARK_TEMPLATE_DEFINE (multiple_malloc_free_benchmark,
171
103
jemalloc_pool_uniform, uniform_alloc_size,
172
104
pool_allocator<jemalloc_pool<os_provider>>);
173
105
UMF_BENCHMARK_REGISTER_F (multiple_malloc_free_benchmark, jemalloc_pool_uniform)
174
- ->Apply(&default_multiple_alloc_uniform_size);
106
+ ->Apply(&default_multiple_alloc_uniform_size)
107
+ ->Apply(&multithreaded);
175
108
176
109
#endif
177
110
@@ -181,14 +114,25 @@ UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark, scalable_pool_fix,
181
114
pool_allocator<scalable_pool<os_provider>>);
182
115
183
116
UMF_BENCHMARK_REGISTER_F (multiple_malloc_free_benchmark, scalable_pool_fix)
184
- ->Apply(&default_multiple_alloc_fix_size);
117
+ ->Apply(&default_multiple_alloc_fix_size)
118
+ ->Apply(&multithreaded);
185
119
186
120
UMF_BENCHMARK_TEMPLATE_DEFINE (multiple_malloc_free_benchmark,
187
121
scalable_pool_uniform, uniform_alloc_size,
188
122
pool_allocator<scalable_pool<os_provider>>);
189
123
190
124
UMF_BENCHMARK_REGISTER_F (multiple_malloc_free_benchmark, scalable_pool_uniform)
191
- ->Apply(&default_multiple_alloc_uniform_size);
125
+ ->Apply(&default_multiple_alloc_uniform_size)
126
+ ->Apply(&multithreaded);
192
127
193
128
#endif
194
- BENCHMARK_MAIN ();
129
+
130
+ // BENCHMARK_MAIN();
131
+ int main (int argc, char **argv) {
132
+ if (initAffinityMask ()) {
133
+ return -1 ;
134
+ }
135
+ benchmark::Initialize (&argc, argv);
136
+ benchmark::RunSpecifiedBenchmarks ();
137
+ benchmark::Shutdown ();
138
+ }
0 commit comments