summaryrefslogtreecommitdiff
path: root/legacy/eina/src/tests/eina_bench_hash.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2008-10-06 12:16:27 +0000
committerCedric BAIL <cedric.bail@free.fr>2008-10-06 12:16:27 +0000
commitb158ab48ed645de8e50bb6dae196f74d2a42a8db (patch)
treeb07707de61687828becadd33dbcae9b78935a77a /legacy/eina/src/tests/eina_bench_hash.c
parent554ad88eff82d426a2d2cff720768b20a12993c6 (diff)
Update hash benchmark to reflect E use (hash population under 2000, more find than add).
Current status : - same performance for evas, eina and glib with les than 500 items. - glib is then faster, eina/evas are second until 800. - glib remain the fastest, eina is second, and evas is starting to drop in performance. SVN revision: 36476
Diffstat (limited to '')
-rw-r--r--legacy/eina/src/tests/eina_bench_hash.c115
1 files changed, 64 insertions, 51 deletions
diff --git a/legacy/eina/src/tests/eina_bench_hash.c b/legacy/eina/src/tests/eina_bench_hash.c
index 243993ad60..6874806621 100644
--- a/legacy/eina/src/tests/eina_bench_hash.c
+++ b/legacy/eina/src/tests/eina_bench_hash.c
@@ -78,6 +78,7 @@ eina_bench_lookup_rbtree(int request)
78 Eina_Rbtree *root = NULL; 78 Eina_Rbtree *root = NULL;
79 Eina_Rbtree *tmp; 79 Eina_Rbtree *tmp;
80 int i; 80 int i;
81 int j;
81 82
82 for (i = 0; i < request; ++i) 83 for (i = 0; i < request; ++i)
83 { 84 {
@@ -94,14 +95,15 @@ eina_bench_lookup_rbtree(int request)
94 95
95 srand(time(NULL)); 96 srand(time(NULL));
96 97
97 for (i = 0; i < request; ++i) 98 for (j = 0; j < 200; ++j)
98 { 99 for (i = 0; i < request; ++i)
99 char tmp_key[10]; 100 {
101 char tmp_key[10];
100 102
101 eina_convert_itoa(rand() % request, tmp_key); 103 eina_convert_itoa(rand() % request, tmp_key);
102 104
103 tmp = eina_rbtree_inline_lookup(root, tmp_key, 10, EINA_RBTREE_CMP_KEY_CB(_eina_bench_rbtree_key), NULL); 105 tmp = eina_rbtree_inline_lookup(root, tmp_key, 10, EINA_RBTREE_CMP_KEY_CB(_eina_bench_rbtree_key), NULL);
104 } 106 }
105 107
106 eina_rbtree_delete(root, EINA_RBTREE_FREE_CB(_eina_bench_rbtree_free), NULL); 108 eina_rbtree_delete(root, EINA_RBTREE_FREE_CB(_eina_bench_rbtree_free), NULL);
107} 109}
@@ -112,6 +114,7 @@ eina_bench_lookup_superfast(int request)
112 Eina_Hash *hash = NULL; 114 Eina_Hash *hash = NULL;
113 int *tmp_val; 115 int *tmp_val;
114 unsigned int i; 116 unsigned int i;
117 unsigned int j;
115 118
116 hash = eina_hash_string_superfast_new(free); 119 hash = eina_hash_string_superfast_new(free);
117 120
@@ -131,14 +134,14 @@ eina_bench_lookup_superfast(int request)
131 134
132 srand(time(NULL)); 135 srand(time(NULL));
133 136
134 for (i = 0; i < (unsigned int) request; ++i) 137 for (j = 0; j < 200; ++j)
135 { 138 for (i = 0; i < (unsigned int) request; ++i)
136 char tmp_key[10]; 139 {
140 char tmp_key[10];
137 141
138 eina_convert_itoa(rand() % request, tmp_key); 142 eina_convert_itoa(rand() % request, tmp_key);
139 143 tmp_val = eina_hash_find(hash, tmp_key);
140 tmp_val = eina_hash_find(hash, tmp_key); 144 }
141 }
142 145
143 eina_hash_free(hash); 146 eina_hash_free(hash);
144} 147}
@@ -149,6 +152,7 @@ eina_bench_lookup_djb2(int request)
149 Eina_Hash *hash = NULL; 152 Eina_Hash *hash = NULL;
150 int *tmp_val; 153 int *tmp_val;
151 unsigned int i; 154 unsigned int i;
155 unsigned int j;
152 156
153 hash = eina_hash_string_djb2_new(free); 157 hash = eina_hash_string_djb2_new(free);
154 158
@@ -168,14 +172,15 @@ eina_bench_lookup_djb2(int request)
168 172
169 srand(time(NULL)); 173 srand(time(NULL));
170 174
171 for (i = 0; i < (unsigned int) request; ++i) 175 for (j = 0; j < 200; ++j)
172 { 176 for (i = 0; i < (unsigned int) request; ++i)
173 char tmp_key[10]; 177 {
178 char tmp_key[10];
174 179
175 eina_convert_itoa(rand() % request, tmp_key); 180 eina_convert_itoa(rand() % request, tmp_key);
176 181
177 tmp_val = eina_hash_find(hash, tmp_key); 182 tmp_val = eina_hash_find(hash, tmp_key);
178 } 183 }
179 184
180 eina_hash_free(hash); 185 eina_hash_free(hash);
181} 186}
@@ -193,6 +198,7 @@ eina_bench_lookup_djb2_inline(int request)
193 Eina_Hash *hash = NULL; 198 Eina_Hash *hash = NULL;
194 Eina_Bench_DJB2 *elm; 199 Eina_Bench_DJB2 *elm;
195 unsigned int i; 200 unsigned int i;
201 unsigned int j;
196 202
197 hash = eina_hash_string_djb2_new(free); 203 hash = eina_hash_string_djb2_new(free);
198 204
@@ -213,15 +219,16 @@ eina_bench_lookup_djb2_inline(int request)
213 219
214 srand(time(NULL)); 220 srand(time(NULL));
215 221
216 for (i = 0; i < (unsigned int) request; ++i) 222 for (j = 0; j < 200; ++j)
217 { 223 for (i = 0; i < (unsigned int) request; ++i)
218 char tmp_key[10]; 224 {
219 int length = 6; 225 char tmp_key[10];
226 int length = 6;
220 227
221 length = eina_convert_itoa(rand() % request, tmp_key) + 1; 228 length = eina_convert_itoa(rand() % request, tmp_key) + 1;
222 229
223 elm = eina_hash_find_by_hash(hash, tmp_key, length, eina_hash_superfast(tmp_key, length)); 230 elm = eina_hash_find_by_hash(hash, tmp_key, length, eina_hash_superfast(tmp_key, length));
224 } 231 }
225 232
226 eina_hash_free(hash); 233 eina_hash_free(hash);
227} 234}
@@ -240,6 +247,7 @@ eina_bench_lookup_ghash(int request)
240 Eina_Bench_Glib *elm; 247 Eina_Bench_Glib *elm;
241 GHashTable *hash; 248 GHashTable *hash;
242 unsigned int i; 249 unsigned int i;
250 unsigned int j;
243 251
244 hash = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, free); 252 hash = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, free);
245 253
@@ -258,14 +266,15 @@ eina_bench_lookup_ghash(int request)
258 266
259 srand(time(NULL)); 267 srand(time(NULL));
260 268
261 for (i = 0; i < (unsigned int) request; ++i) 269 for (j = 0; j < 200; ++j)
262 { 270 for (i = 0; i < (unsigned int) request; ++i)
263 char tmp_key[10]; 271 {
272 char tmp_key[10];
264 273
265 eina_convert_itoa(rand() % request, tmp_key); 274 eina_convert_itoa(rand() % request, tmp_key);
266 275
267 elm = g_hash_table_lookup(hash, tmp_key); 276 elm = g_hash_table_lookup(hash, tmp_key);
268 } 277 }
269 278
270 g_hash_table_destroy(hash); 279 g_hash_table_destroy(hash);
271} 280}
@@ -280,6 +289,7 @@ eina_bench_lookup_evas(int request)
280 int *tmp_val; 289 int *tmp_val;
281 Eina_Array_Iterator it; 290 Eina_Array_Iterator it;
282 unsigned int i; 291 unsigned int i;
292 unsigned int j;
283 293
284 array = eina_array_new(1000); 294 array = eina_array_new(1000);
285 295
@@ -301,14 +311,15 @@ eina_bench_lookup_evas(int request)
301 311
302 srand(time(NULL)); 312 srand(time(NULL));
303 313
304 for (i = 0; i < (unsigned int) request; ++i) 314 for (j = 0; j < 200; ++j)
305 { 315 for (i = 0; i < (unsigned int) request; ++i)
306 char tmp_key[10]; 316 {
317 char tmp_key[10];
307 318
308 eina_convert_itoa(rand() % request, tmp_key); 319 eina_convert_itoa(rand() % request, tmp_key);
309 320
310 tmp_val = evas_hash_find(hash, tmp_key); 321 tmp_val = evas_hash_find(hash, tmp_key);
311 } 322 }
312 323
313 evas_hash_free(hash); 324 evas_hash_free(hash);
314 325
@@ -333,6 +344,7 @@ eina_bench_lookup_ecore(int request)
333 Ecore_Hash *hash = NULL; 344 Ecore_Hash *hash = NULL;
334 Eina_Bench_Ecore *elm; 345 Eina_Bench_Ecore *elm;
335 unsigned int i; 346 unsigned int i;
347 unsigned int j;
336 348
337 hash = ecore_hash_new(ecore_str_hash, ecore_str_compare); 349 hash = ecore_hash_new(ecore_str_hash, ecore_str_compare);
338 350
@@ -353,14 +365,15 @@ eina_bench_lookup_ecore(int request)
353 365
354 srand(time(NULL)); 366 srand(time(NULL));
355 367
356 for (i = 0; i < (unsigned int) request; ++i) 368 for (j = 0; j < 200; ++j)
357 { 369 for (i = 0; i < (unsigned int) request; ++i)
358 char tmp_key[10]; 370 {
371 char tmp_key[10];
359 372
360 eina_convert_itoa(rand() % request, tmp_key); 373 eina_convert_itoa(rand() % request, tmp_key);
361 374
362 elm = ecore_hash_get(hash, tmp_key); 375 elm = ecore_hash_get(hash, tmp_key);
363 } 376 }
364 377
365 ecore_hash_destroy(hash); 378 ecore_hash_destroy(hash);
366} 379}
@@ -368,17 +381,17 @@ eina_bench_lookup_ecore(int request)
368 381
369void eina_bench_hash(Eina_Benchmark *bench) 382void eina_bench_hash(Eina_Benchmark *bench)
370{ 383{
371 eina_benchmark_register(bench, "superfast-lookup", EINA_BENCHMARK(eina_bench_lookup_superfast), 10, 8000, 50); 384 eina_benchmark_register(bench, "superfast-lookup", EINA_BENCHMARK(eina_bench_lookup_superfast), 10, 2000, 10);
372 eina_benchmark_register(bench, "djb2-lookup", EINA_BENCHMARK(eina_bench_lookup_djb2), 10, 8000, 50); 385 eina_benchmark_register(bench, "djb2-lookup", EINA_BENCHMARK(eina_bench_lookup_djb2), 10, 2000, 10);
373 eina_benchmark_register(bench, "djb2-lookup-inline", EINA_BENCHMARK(eina_bench_lookup_djb2_inline), 10, 8000, 50); 386 eina_benchmark_register(bench, "djb2-lookup-inline", EINA_BENCHMARK(eina_bench_lookup_djb2_inline), 10, 2000, 10);
374 eina_benchmark_register(bench, "rbtree", EINA_BENCHMARK(eina_bench_lookup_rbtree), 10, 8000, 50); 387 eina_benchmark_register(bench, "rbtree", EINA_BENCHMARK(eina_bench_lookup_rbtree), 10, 2000, 10);
375#ifdef EINA_BENCH_HAVE_GLIB 388#ifdef EINA_BENCH_HAVE_GLIB
376 eina_benchmark_register(bench, "ghash-lookup", EINA_BENCHMARK(eina_bench_lookup_ghash), 10, 8000, 50); 389 eina_benchmark_register(bench, "ghash-lookup", EINA_BENCHMARK(eina_bench_lookup_ghash), 10, 2000, 10);
377#endif 390#endif
378#ifdef EINA_BENCH_HAVE_EVAS 391#ifdef EINA_BENCH_HAVE_EVAS
379 eina_benchmark_register(bench, "evas-lookup", EINA_BENCHMARK(eina_bench_lookup_evas), 10, 8000, 50); 392 eina_benchmark_register(bench, "evas-lookup", EINA_BENCHMARK(eina_bench_lookup_evas), 10, 2000, 10);
380#endif 393#endif
381#ifdef EINA_BENCH_HAVE_ECORE 394#ifdef EINA_BENCH_HAVE_ECORE
382 eina_benchmark_register(bench, "ecore-lookup", EINA_BENCHMARK(eina_bench_lookup_ecore), 10, 8000, 50); 395 eina_benchmark_register(bench, "ecore-lookup", EINA_BENCHMARK(eina_bench_lookup_ecore), 10, 2000, 10);
383#endif 396#endif
384} 397}