aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/eina/src/tests/eina_bench_stringshare.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/eina/src/tests/eina_bench_stringshare.c')
-rw-r--r--libraries/eina/src/tests/eina_bench_stringshare.c185
1 files changed, 0 insertions, 185 deletions
diff --git a/libraries/eina/src/tests/eina_bench_stringshare.c b/libraries/eina/src/tests/eina_bench_stringshare.c
deleted file mode 100644
index 22d18fa..0000000
--- a/libraries/eina/src/tests/eina_bench_stringshare.c
+++ /dev/null
@@ -1,185 +0,0 @@
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
39static void
40eina_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 srand(time(NULL));
57
58 for (j = 0; j < 200; ++j)
59 for (i = 0; i < request; ++i)
60 {
61 char build[64] = "string_";
62
63 eina_convert_xtoa(rand() % request, build + 7);
64 tmp = eina_stringshare_add(build);
65 }
66
67 /* Suppress warnings as we really don't want to do anything. */
68 (void) tmp;
69 eina_shutdown();
70}
71
72#ifdef EINA_BENCH_HAVE_GLIB
73static void
74eina_bench_stringchunk_job(int request)
75{
76 GStringChunk *chunk;
77 unsigned int j;
78 int i;
79
80 chunk = g_string_chunk_new(4096);
81
82 for (i = 0; i < request; ++i)
83 {
84 char build[64] = "string_";
85
86 eina_convert_xtoa(i, build + 7);
87 g_string_chunk_insert_const(chunk, build);
88 }
89
90 srand(time(NULL));
91
92 for (j = 0; j < 200; ++j)
93 for (i = 0; i < request; ++i)
94 {
95 char build[64] = "string_";
96
97 eina_convert_xtoa(rand() % request, build + 7);
98 g_string_chunk_insert_const(chunk, build);
99 }
100
101 g_string_chunk_free(chunk);
102}
103#endif
104
105static void
106eina_bench_evas_job(int request)
107{
108 const char *tmp;
109 unsigned int j;
110 int i;
111
112 for (i = 0; i < request; ++i)
113 {
114 char build[64] = "string_";
115
116 eina_convert_xtoa(i, build + 7);
117 tmp = evas_stringshare_add(build);
118 }
119
120 srand(time(NULL));
121
122 for (j = 0; j < 200; ++j)
123 for (i = 0; i < request; ++i)
124 {
125 char build[64] = "string_";
126
127 eina_convert_xtoa(rand() % request, build + 7);
128 tmp = evas_stringshare_add(build);
129 }
130
131 /* Suppress warnings as we really don't want to do anything. */
132 (void) tmp;
133}
134
135static void
136eina_bench_ecore_job(int request)
137{
138 const char *tmp;
139 unsigned int j;
140 int i;
141
142 ecore_string_init();
143
144 for (i = 0; i < request; ++i)
145 {
146 char build[64] = "string_";
147
148 eina_convert_xtoa(i, build + 7);
149 tmp = ecore_string_instance(build);
150 }
151
152 srand(time(NULL));
153
154 for (j = 0; j < 200; ++j)
155 for (i = 0; i < request; ++i)
156 {
157 char build[64] = "string_";
158
159 eina_convert_xtoa(rand() % request, build + 7);
160 tmp = ecore_string_instance(build);
161 }
162
163 /* Suppress warnings as we really don't want to do anything. */
164 (void) tmp;
165
166 ecore_string_shutdown();
167}
168
169void eina_bench_stringshare(Eina_Benchmark *bench)
170{
171 eina_benchmark_register(bench, "stringshare",
172 EINA_BENCHMARK(
173 eina_bench_stringshare_job), 100, 20100, 500);
174#ifdef EINA_BENCH_HAVE_GLIB
175 eina_benchmark_register(bench, "stringchunk (glib)",
176 EINA_BENCHMARK(
177 eina_bench_stringchunk_job), 100, 20100, 500);
178#endif
179 eina_benchmark_register(bench, "stringshare (evas)",
180 EINA_BENCHMARK(
181 eina_bench_evas_job), 100, 20100, 500);
182 eina_benchmark_register(bench, "stringshare (ecore)",
183 EINA_BENCHMARK(
184 eina_bench_ecore_job), 100, 20100, 500);
185}