3030// The exact meaning of each argument depends on the benchmark, allocator, and size components used.
3131// Refer to the 'argsName()' function in each component to find detailed descriptions of these arguments.
3232
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) {
3634 benchmark->Threads (4 );
3735 benchmark->Threads (1 );
3836}
3937
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- #ifdef UMF_POOL_DISJOINT_ENABLED
70- UMF_BENCHMARK_TEMPLATE_DEFINE (alloc_benchmark, disjoint_pool_fix,
71- fixed_alloc_size,
72- pool_allocator<disjoint_pool<os_provider>>);
73- UMF_BENCHMARK_REGISTER_F (alloc_benchmark, disjoint_pool_fix)
74- ->Apply(&default_alloc_fix_size);
75-
76- // TODO: debug why this crashes
77- /* UMF_BENCHMARK_TEMPLATE_DEFINE(alloc_benchmark, disjoint_pool_uniform,
78- uniform_alloc_size,
79- pool_allocator<disjoint_pool<os_provider>>);
80- UMF_BENCHMARK_REGISTER_F(alloc_benchmark, disjoint_pool_uniform)
81- ->Apply(&default_alloc_uniform_size);
82- */
83- #endif
84-
85- #ifdef UMF_POOL_JEMALLOC_ENABLED
86- UMF_BENCHMARK_TEMPLATE_DEFINE (alloc_benchmark, jemalloc_pool_fix,
87- fixed_alloc_size,
88- pool_allocator<jemalloc_pool<os_provider>>);
89- UMF_BENCHMARK_REGISTER_F (alloc_benchmark, jemalloc_pool_fix)
90- ->Apply(&default_alloc_fix_size);
91-
92- UMF_BENCHMARK_TEMPLATE_DEFINE (alloc_benchmark, jemalloc_pool_uniform,
93- uniform_alloc_size,
94- pool_allocator<jemalloc_pool<os_provider>>);
95- UMF_BENCHMARK_REGISTER_F (alloc_benchmark, jemalloc_pool_uniform)
96- ->Apply(&default_alloc_uniform_size);
97-
98- #endif
99- #ifdef UMF_POOL_SCALABLE_ENABLED
100- UMF_BENCHMARK_TEMPLATE_DEFINE (alloc_benchmark, scalable_pool_fix,
101- fixed_alloc_size,
102- pool_allocator<scalable_pool<os_provider>>);
103-
104- UMF_BENCHMARK_REGISTER_F (alloc_benchmark, scalable_pool_fix)
105- ->Apply(&default_alloc_fix_size);
106-
107- UMF_BENCHMARK_TEMPLATE_DEFINE (alloc_benchmark, scalable_pool_uniform,
108- uniform_alloc_size,
109- pool_allocator<scalable_pool<os_provider>>);
110-
111- UMF_BENCHMARK_REGISTER_F (alloc_benchmark, scalable_pool_uniform)
112- ->Apply(&default_alloc_uniform_size);
113- #endif
114- // Multiple allocs/free
11538static void
11639default_multiple_alloc_fix_size (benchmark::internal::Benchmark *benchmark) {
117- benchmark->Args ({10000 , 4096 });
118- benchmark->Threads (4 );
119- benchmark->Threads (1 );
40+ benchmark->Args ({10000 , 1 , 4096 });
41+ benchmark->Iterations (500000 );
12042}
12143
12244static void
12345default_multiple_alloc_uniform_size (benchmark::internal::Benchmark *benchmark) {
124- benchmark->Args ({10000 , 8 , 64 * 1024 , 8 });
125- benchmark->Threads ( 4 );
126- benchmark->Threads ( 1 );
46+ benchmark->Args ({10000 , 1 , 8 , 4096 , 8 });
47+ benchmark->Args ({ 10000 , 1 , 8 , 128 , 8 } );
48+ benchmark->Iterations ( 500000 );
12749}
12850
12951UMF_BENCHMARK_TEMPLATE_DEFINE (multiple_malloc_free_benchmark, glibc_fix,
13052 fixed_alloc_size, glibc_malloc);
13153
13254UMF_BENCHMARK_REGISTER_F (multiple_malloc_free_benchmark, glibc_fix)
133- ->Apply(&default_multiple_alloc_fix_size);
55+ ->Apply(&default_multiple_alloc_fix_size)
56+ ->Apply(&multithreaded);
13457
13558UMF_BENCHMARK_TEMPLATE_DEFINE (multiple_malloc_free_benchmark, glibc_uniform,
13659 uniform_alloc_size, glibc_malloc);
13760UMF_BENCHMARK_REGISTER_F (multiple_malloc_free_benchmark, glibc_uniform)
138- ->Apply(&default_multiple_alloc_uniform_size);
61+ ->Apply(&default_multiple_alloc_uniform_size)
62+ ->Apply(&multithreaded);
13963
14064UMF_BENCHMARK_TEMPLATE_DEFINE (multiple_malloc_free_benchmark, proxy_pool,
14165 fixed_alloc_size,
14266 pool_allocator<proxy_pool<os_provider>>);
14367
14468UMF_BENCHMARK_REGISTER_F (multiple_malloc_free_benchmark, proxy_pool)
145- ->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 );
14672
14773UMF_BENCHMARK_TEMPLATE_DEFINE (multiple_malloc_free_benchmark, os_provider,
14874 fixed_alloc_size,
14975 provider_allocator<os_provider>);
15076UMF_BENCHMARK_REGISTER_F (multiple_malloc_free_benchmark, os_provider)
151- ->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 );
15280
15381#ifdef UMF_POOL_DISJOINT_ENABLED
15482UMF_BENCHMARK_TEMPLATE_DEFINE (multiple_malloc_free_benchmark, disjoint_pool_fix,
15583 fixed_alloc_size,
15684 pool_allocator<disjoint_pool<os_provider>>);
15785UMF_BENCHMARK_REGISTER_F (multiple_malloc_free_benchmark, disjoint_pool_fix)
158- ->Apply(&default_multiple_alloc_fix_size);
86+ ->Apply(&default_multiple_alloc_fix_size)
87+ ->Apply(&multithreaded);
15988
16089// TODO: debug why this crashes
16190/* UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark,
@@ -171,13 +100,15 @@ UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark, jemalloc_pool_fix,
171100 fixed_alloc_size,
172101 pool_allocator<jemalloc_pool<os_provider>>);
173102UMF_BENCHMARK_REGISTER_F (multiple_malloc_free_benchmark, jemalloc_pool_fix)
174- ->Apply(&default_multiple_alloc_fix_size);
103+ ->Apply(&default_multiple_alloc_fix_size)
104+ ->Apply(&multithreaded);
175105
176106UMF_BENCHMARK_TEMPLATE_DEFINE (multiple_malloc_free_benchmark,
177107 jemalloc_pool_uniform, uniform_alloc_size,
178108 pool_allocator<jemalloc_pool<os_provider>>);
179109UMF_BENCHMARK_REGISTER_F (multiple_malloc_free_benchmark, jemalloc_pool_uniform)
180- ->Apply(&default_multiple_alloc_uniform_size);
110+ ->Apply(&default_multiple_alloc_uniform_size)
111+ ->Apply(&multithreaded);
181112
182113#endif
183114
@@ -187,14 +118,25 @@ UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark, scalable_pool_fix,
187118 pool_allocator<scalable_pool<os_provider>>);
188119
189120UMF_BENCHMARK_REGISTER_F (multiple_malloc_free_benchmark, scalable_pool_fix)
190- ->Apply(&default_multiple_alloc_fix_size);
121+ ->Apply(&default_multiple_alloc_fix_size)
122+ ->Apply(&multithreaded);
191123
192124UMF_BENCHMARK_TEMPLATE_DEFINE (multiple_malloc_free_benchmark,
193125 scalable_pool_uniform, uniform_alloc_size,
194126 pool_allocator<scalable_pool<os_provider>>);
195127
196128UMF_BENCHMARK_REGISTER_F (multiple_malloc_free_benchmark, scalable_pool_uniform)
197- ->Apply(&default_multiple_alloc_uniform_size);
129+ ->Apply(&default_multiple_alloc_uniform_size)
130+ ->Apply(&multithreaded);
198131
199132#endif
200- BENCHMARK_MAIN ();
133+
134+ // BENCHMARK_MAIN();
135+ int main (int argc, char **argv) {
136+ if (initAffinityMask ()) {
137+ return -1 ;
138+ }
139+ benchmark::Initialize (&argc, argv);
140+ benchmark::RunSpecifiedBenchmarks ();
141+ benchmark::Shutdown ();
142+ }
0 commit comments