1 /* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
23 #ifdef EINA_BENCH_HAVE_GLIB
27 #include "eina_bench.h"
31 _eina_mempool_bench(Eina_Mempool *mp, int request)
38 array = eina_array_new(32);
40 for (i = 0; i < 100; ++i)
42 for (j = 0; j < request; ++j)
44 eina_array_push(array, eina_mempool_malloc(mp, sizeof (int)));
47 for (j = 0; j < request; ++j)
49 eina_mempool_free(mp, eina_array_pop(array));
53 eina_array_free(array);
57 #ifdef EINA_BUILD_CHAINED_POOL
59 eina_mempool_chained_mempool(int request)
63 mp = eina_mempool_add("chained_mempool", "test", NULL, sizeof (int), 256);
64 _eina_mempool_bench(mp, request);
69 #ifdef EINA_BUILD_PASS_THROUGH
71 eina_mempool_pass_through(int request)
75 mp = eina_mempool_add("pass_through", "test", NULL, sizeof (int), 8, 0);
76 _eina_mempool_bench(mp, request);
81 #ifdef EINA_BUILD_FIXED_BITMAP
83 eina_mempool_fixed_bitmap(int request)
87 mp = eina_mempool_add("fixed_bitmap", "test", NULL, sizeof (int));
88 _eina_mempool_bench(mp, request);
93 #ifdef EINA_BUILD_EMEMOA_FIXED
95 eina_mempool_ememoa_fixed(int request)
99 mp = eina_mempool_add("ememoa_fixed", "test", NULL, sizeof (int), 8, 0);
100 _eina_mempool_bench(mp, request);
101 eina_mempool_del(mp);
105 #ifdef EINA_BUILD_EMEMOA_UNKNOWN
107 eina_mempool_ememoa_unknown(int request)
111 mp = eina_mempool_add("ememoa_unknown",
120 _eina_mempool_bench(mp, request);
121 eina_mempool_del(mp);
125 #ifdef EINA_BENCH_HAVE_GLIB
127 eina_mempool_glib(int request)
134 array = eina_array_new(32);
136 for (i = 0; i < 100; ++i)
138 for (j = 0; j < request; ++j)
140 eina_array_push(array, g_slice_alloc(sizeof (int)));
143 for (j = 0; j < request; ++j)
145 g_slice_free1(sizeof (int), eina_array_pop(array));
149 eina_array_free(array);
156 eina_bench_mempool(Eina_Benchmark *bench)
158 #ifdef EINA_BUILD_CHAINED_POOL
159 eina_benchmark_register(bench, "chained mempool",
161 eina_mempool_chained_mempool), 10, 10000, 10);
163 #ifdef EINA_BUILD_PASS_THROUGH
164 eina_benchmark_register(bench, "pass through",
166 eina_mempool_pass_through), 10, 10000, 10);
168 #ifdef EINA_BUILD_FIXED_BITMAP
169 eina_benchmark_register(bench, "fixed bitmap",
171 eina_mempool_fixed_bitmap), 10, 10000, 10);
173 #ifdef EINA_BUILD_EMEMOA_FIXED
174 eina_benchmark_register(bench, "ememoa fixed",
176 eina_mempool_ememoa_fixed), 10, 10000, 10);
178 #ifdef EINA_BUILD_EMEMOA_UNKNOWN
179 eina_benchmark_register(bench, "ememoa unknown",
181 eina_mempool_ememoa_unknown), 10, 10000, 10);
183 #ifdef EINA_BENCH_HAVE_GLIB
184 eina_benchmark_register(bench, "gslice",
186 eina_mempool_glib), 10, 10000, 10);