efl

Форк
0
/
eina_bench_stringshare.c 
177 строк · 4.2 Кб
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 <time.h>
26

27
#ifdef EINA_BENCH_HAVE_GLIB
28
# include <glib.h>
29
#endif
30

31
#include "Evas_Data.h"
32
#include "Ecore_Data.h"
33

34
#include "eina_stringshare.h"
35
#include "eina_bench.h"
36
#include "eina_convert.h"
37
#include "eina_main.h"
38

39
static void
40
eina_bench_stringshare_job(int request)
41
{
42
   const char *tmp;
43
   unsigned int j;
44
   int i;
45

46
   eina_init();
47

48
   for (i = 0; i < request; ++i)
49
     {
50
        char build[64] = "string_";
51

52
        eina_convert_xtoa(i, build + 7);
53
        tmp = eina_stringshare_add(build);
54
     }
55

56
   for (j = 0; j < 200; ++j)
57
      for (i = 0; i < request; ++i)
58
        {
59
           char build[64] = "string_";
60

61
           eina_convert_xtoa(rand() % request, build + 7);
62
           tmp = eina_stringshare_add(build);
63
        }
64

65
   /* Suppress warnings as we really don't want to do anything. */
66
   (void) tmp;
67
   eina_shutdown();
68
}
69

70
#ifdef EINA_BENCH_HAVE_GLIB
71
static void
72
eina_bench_stringchunk_job(int request)
73
{
74
   GStringChunk *chunk;
75
   unsigned int j;
76
   int i;
77

78
   chunk = g_string_chunk_new(4096);
79

80
   for (i = 0; i < request; ++i)
81
     {
82
        char build[64] = "string_";
83

84
        eina_convert_xtoa(i, build + 7);
85
        g_string_chunk_insert_const(chunk, build);
86
     }
87

88
   for (j = 0; j < 200; ++j)
89
      for (i = 0; i < request; ++i)
90
        {
91
           char build[64] = "string_";
92

93
           eina_convert_xtoa(rand() % request, build + 7);
94
           g_string_chunk_insert_const(chunk, build);
95
        }
96

97
   g_string_chunk_free(chunk);
98
}
99
#endif
100

101
static void
102
eina_bench_evas_job(int request)
103
{
104
   const char *tmp;
105
   unsigned int j;
106
   int i;
107

108
   for (i = 0; i < request; ++i)
109
     {
110
        char build[64] = "string_";
111

112
        eina_convert_xtoa(i, build + 7);
113
        tmp = evas_stringshare_add(build);
114
     }
115

116
   for (j = 0; j < 200; ++j)
117
      for (i = 0; i < request; ++i)
118
        {
119
           char build[64] = "string_";
120

121
           eina_convert_xtoa(rand() % request, build + 7);
122
           tmp = evas_stringshare_add(build);
123
        }
124

125
   /* Suppress warnings as we really don't want to do anything. */
126
   (void) tmp;
127
}
128

129
static void
130
eina_bench_ecore_job(int request)
131
{
132
   const char *tmp;
133
   unsigned int j;
134
   int i;
135

136
   //ecore_string_init();
137

138
   for (i = 0; i < request; ++i)
139
     {
140
        char build[64] = "string_";
141

142
        eina_convert_xtoa(i, build + 7);
143
        //tmp = ecore_string_instance(build);
144
     }
145

146
   for (j = 0; j < 200; ++j)
147
      for (i = 0; i < request; ++i)
148
        {
149
           char build[64] = "string_";
150

151
           eina_convert_xtoa(rand() % request, build + 7);
152
           //tmp = ecore_string_instance(build);
153
        }
154

155
   /* Suppress warnings as we really don't want to do anything. */
156
   (void) tmp;
157

158
   //ecore_string_shutdown();
159
}
160

161
void eina_bench_stringshare(Eina_Benchmark *bench)
162
{
163
   eina_benchmark_register(bench, "stringshare",
164
                           EINA_BENCHMARK(
165
                              eina_bench_stringshare_job), 100, 20100, 500);
166
#ifdef EINA_BENCH_HAVE_GLIB
167
   eina_benchmark_register(bench, "stringchunk (glib)",
168
                           EINA_BENCHMARK(
169
                              eina_bench_stringchunk_job), 100, 20100, 500);
170
#endif
171
   eina_benchmark_register(bench, "stringshare (evas)",
172
                           EINA_BENCHMARK(
173
                              eina_bench_evas_job),        100, 20100, 500);
174
   eina_benchmark_register(bench, "stringshare (ecore)",
175
                           EINA_BENCHMARK(
176
                              eina_bench_ecore_job),       100, 20100, 500);
177
}
178

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

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

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

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