efl

Форк
0
/
eina_bench.c 
135 строк · 3.5 Кб
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

30
typedef struct _Eina_Benchmark_Case Eina_Benchmark_Case;
31
struct _Eina_Benchmark_Case
32
{
33
   const char *bench_case;
34
   void (*build)(Eina_Benchmark *bench);
35
   Eina_Bool run_by_default;
36
};
37

38
static const Eina_Benchmark_Case etc[] = {
39
   { "Hash_Short_Key", eina_bench_crc_hash_short, EINA_TRUE },
40
   { "Hash_Medium_Key", eina_bench_crc_hash_medium, EINA_TRUE },
41
   { "Hash_Large_key", eina_bench_crc_hash_large, EINA_TRUE },
42
   { "Array vs List vs Inlist", eina_bench_array, EINA_TRUE },
43
   { "Stringshare", eina_bench_stringshare, EINA_TRUE },
44
   { "Convert", eina_bench_convert, EINA_TRUE },
45
   { "Sort", eina_bench_sort, EINA_TRUE },
46
   { "Mempool", eina_bench_mempool, EINA_TRUE },
47
   { "Rectangle_Pool", eina_bench_rectangle_pool, EINA_TRUE },
48
   { "Render Loop", eina_bench_quadtree, EINA_FALSE },
49
   { NULL, NULL, EINA_FALSE }
50
};
51

52
/* FIXME this is a copy from eina_test_mempool
53
 * we should remove the duplication
54
 */
55
static Eina_Array *_modules;
56
static void _mempool_init(void)
57
{
58
   eina_init();
59
   /* force modules to be loaded in case they are not installed */
60
   _modules = eina_module_list_get(NULL,
61
                                   PACKAGE_BUILD_DIR "/src/modules/eina",
62
                                   EINA_TRUE,
63
                                   NULL,
64
                                   NULL);
65
   eina_module_list_load(_modules);
66
}
67

68
static void _mempool_shutdown(void)
69
{
70
   eina_module_list_free(_modules);
71
   if (_modules)
72
     {
73
        Eina_Array_Iterator it;
74
        char* module;
75
        unsigned int i;
76

77
        EINA_ARRAY_ITER_NEXT(_modules, i, module, it)
78
          free(module);
79
        eina_array_free(_modules);
80
     }
81
   eina_shutdown();
82
}
83

84
int
85
main(int argc, char **argv)
86
{
87
   Eina_Benchmark *test;
88
   unsigned int i;
89

90
   _mempool_init();
91

92
   eina_init();
93

94
   switch (argc)
95
     {
96
      case 1:
97
         for (i = 0; etc[i].bench_case; ++i)
98
           if (etc[i].run_by_default)
99
             {
100
                test = eina_benchmark_new(etc[i].bench_case, "default");
101
                if (!test) continue;
102

103
                etc[i].build(test);
104

105
                eina_benchmark_run(test);
106

107
                eina_benchmark_free(test);
108
             }
109
         break;
110
      case 2:
111
         for (i = 0; etc[i].bench_case; ++i)
112
           {
113
              if (strcasecmp(etc[i].bench_case, argv[1]))
114
                continue;
115

116
              test = eina_benchmark_new(etc[i].bench_case, argv[1]);
117
              if (!test)
118
                continue;
119

120
              etc[i].build(test);
121

122
              eina_benchmark_run(test);
123

124
              eina_benchmark_free(test);
125

126
              break;
127
           }
128
         break;
129
     }
130

131
   eina_shutdown();
132

133
   _mempool_shutdown();
134
   return 0;
135
}
136

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.