aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/eina/src/tests/eina_bench.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/eina/src/tests/eina_bench.c')
-rw-r--r--libraries/eina/src/tests/eina_bench.c105
1 files changed, 105 insertions, 0 deletions
diff --git a/libraries/eina/src/tests/eina_bench.c b/libraries/eina/src/tests/eina_bench.c
new file mode 100644
index 0000000..a4eadbe
--- /dev/null
+++ b/libraries/eina/src/tests/eina_bench.c
@@ -0,0 +1,105 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
3 *
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.
8 *
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.
13 *
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/>.
17 */
18
19#ifdef HAVE_CONFIG_H
20# include "config.h"
21#endif
22
23#include <stdlib.h>
24#include <stdio.h>
25#include <limits.h>
26
27#include "eina_bench.h"
28#include "Eina.h"
29
30typedef struct _Eina_Benchmark_Case Eina_Benchmark_Case;
31struct _Eina_Benchmark_Case
32{
33 const char *bench_case;
34 void (*build)(Eina_Benchmark *bench);
35};
36
37static const Eina_Benchmark_Case etc[] = {
38 { "Hash", eina_bench_hash },
39 /* { "Array vs List vs Inlist", eina_bench_array }, */
40 /* { "Stringshare", eina_bench_stringshare }, */
41 /* { "Convert", eina_bench_convert }, */
42 /* { "Sort", eina_bench_sort }, */
43 /* { "Mempool", eina_bench_mempool }, */
44 /* { "Rectangle_Pool", eina_bench_rectangle_pool }, */
45 // { "Render Loop", eina_bench_quadtree },
46 { NULL, NULL }
47};
48
49/* FIXME this is a copy from eina_test_mempool
50 * we should remove the duplication
51 */
52static Eina_Array *_modules;
53static void _mempool_init(void)
54{
55 eina_init();
56 /* force modules to be loaded in case they are not installed */
57 _modules = eina_module_list_get(NULL,
58 PACKAGE_BUILD_DIR "/src/modules",
59 EINA_TRUE,
60 NULL,
61 NULL);
62 eina_module_list_load(_modules);
63}
64
65static void _mempool_shutdown(void)
66{
67 eina_module_list_free(_modules);
68 /* TODO delete the list */
69 eina_shutdown();
70}
71
72int
73main(int argc, char **argv)
74{
75 Eina_Benchmark *test;
76 Eina_Array *ea;
77 unsigned int i;
78
79 if (argc != 2)
80 return -1;
81
82 _mempool_init();
83
84 eina_init();
85
86 for (i = 0; etc[i].bench_case; ++i)
87 {
88 test = eina_benchmark_new(etc[i].bench_case, argv[1]);
89 if (!test)
90 continue;
91
92 etc[i].build(test);
93
94 ea = eina_benchmark_run(test);
95
96 eina_benchmark_free(test);
97 }
98
99 eina_bench_e17();
100
101 eina_shutdown();
102
103 _mempool_shutdown();
104 return 0;
105}