summaryrefslogtreecommitdiff
path: root/legacy/eina/src/tests/eina_bench_hash.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2008-08-26 10:23:45 +0000
committerCedric BAIL <cedric.bail@free.fr>2008-08-26 10:23:45 +0000
commit4390a37a70773e809a3dc29ef76427fe4085cf62 (patch)
tree30499ed6f062e9bf58f87d7e67814358ae1ab7d6 /legacy/eina/src/tests/eina_bench_hash.c
parent3878e945fb12f465e30f7e3e9f5c0174b49b4c82 (diff)
Add eina_array_pop and rename eina_array_append by eina_array_push.
SVN revision: 35679
Diffstat (limited to '')
-rw-r--r--legacy/eina/src/tests/eina_bench_hash.c54
1 files changed, 51 insertions, 3 deletions
diff --git a/legacy/eina/src/tests/eina_bench_hash.c b/legacy/eina/src/tests/eina_bench_hash.c
index ee9dd86a18..a47e8ce65c 100644
--- a/legacy/eina/src/tests/eina_bench_hash.c
+++ b/legacy/eina/src/tests/eina_bench_hash.c
@@ -26,6 +26,54 @@
26#include "eina_bench.h" 26#include "eina_bench.h"
27 27
28static void 28static void
29eina_bench_lookup_rbtree(int request)
30{
31 Eina_Hash *hash = NULL;
32 Eina_Array *array = NULL;
33 int *tmp_val;
34 Eina_Array_Iterator it;
35 unsigned int i;
36
37 array = eina_array_new(1000);
38
39 hash = eina_hash_string_superfast_new();
40
41 for (i = 0; i < (unsigned int) request; ++i)
42 {
43 char tmp_key[10];
44
45 tmp_val = malloc(sizeof (int));
46
47 if (!tmp_val) continue ;
48
49 snprintf(tmp_key, 10, "%i", i);
50 *tmp_val = i;
51
52 eina_hash_add(hash, tmp_key, tmp_val);
53
54 eina_array_push(array, tmp_val);
55 }
56
57 srand(time(NULL));
58
59 for (i = 0; i < (unsigned int) request; ++i)
60 {
61 char tmp_key[10];
62
63 snprintf(tmp_key, 10, "%i", rand() % request);
64
65 tmp_val = eina_hash_find(hash, tmp_key);
66 }
67
68 eina_hash_free(hash);
69
70 EINA_ARRAY_ITER_NEXT(array, i, tmp_val, it)
71 free(tmp_val);
72
73 eina_array_free(array);
74}
75
76static void
29eina_bench_lookup_superfast(int request) 77eina_bench_lookup_superfast(int request)
30{ 78{
31 Eina_Hash *hash = NULL; 79 Eina_Hash *hash = NULL;
@@ -51,7 +99,7 @@ eina_bench_lookup_superfast(int request)
51 99
52 eina_hash_add(hash, tmp_key, tmp_val); 100 eina_hash_add(hash, tmp_key, tmp_val);
53 101
54 eina_array_append(array, tmp_val); 102 eina_array_push(array, tmp_val);
55 } 103 }
56 104
57 srand(time(NULL)); 105 srand(time(NULL));
@@ -99,7 +147,7 @@ eina_bench_lookup_djb2(int request)
99 147
100 eina_hash_add(hash, tmp_key, tmp_val); 148 eina_hash_add(hash, tmp_key, tmp_val);
101 149
102 eina_array_append(array, tmp_val); 150 eina_array_push(array, tmp_val);
103 } 151 }
104 152
105 srand(time(NULL)); 153 srand(time(NULL));
@@ -148,7 +196,7 @@ eina_bench_lookup_djb2_inline(int request)
148 196
149 eina_hash_add_by_hash(hash, tmp_key, length, eina_hash_djb2(tmp_key, length), tmp_val); 197 eina_hash_add_by_hash(hash, tmp_key, length, eina_hash_djb2(tmp_key, length), tmp_val);
150 198
151 eina_array_append(array, tmp_val); 199 eina_array_push(array, tmp_val);
152 } 200 }
153 201
154 srand(time(NULL)); 202 srand(time(NULL));