summaryrefslogtreecommitdiff
path: root/src/benchmarks/eina/eina_bench_promise.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2016-11-07 11:12:33 -0800
committerCedric BAIL <cedric@osg.samsung.com>2016-11-07 11:12:33 -0800
commit5db949196e4696c3e38c88b84741cf71469ccf3a (patch)
treec3a7206856f415ea2a29b6293e2dfe6ff0806763 /src/benchmarks/eina/eina_bench_promise.c
parent5038f2551a0b09a1a3566768e41b58468267fef0 (diff)
eina: remove benchmark for Eina_Promise.
Diffstat (limited to '')
-rw-r--r--src/benchmarks/eina/eina_bench_promise.c309
1 files changed, 0 insertions, 309 deletions
diff --git a/src/benchmarks/eina/eina_bench_promise.c b/src/benchmarks/eina/eina_bench_promise.c
deleted file mode 100644
index 6baabac9a6..0000000000
--- a/src/benchmarks/eina/eina_bench_promise.c
+++ /dev/null
@@ -1,309 +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#include "Evas_Data.h"
28#include "Ecore_Data.h"
29
30#include "eina_stringshare.h"
31#include "eina_bench.h"
32#include "eina_convert.h"
33#include "eina_main.h"
34
35#include <assert.h>
36
37#include <Eina.h>
38
39struct value_type
40{
41 int x;
42 int y;
43 int w;
44 int h;
45};
46
47void cb(void* data EINA_UNUSED, void* value)
48{
49 struct value_type* p = value;
50 volatile int v = p->x * p->y * p->w * p->h;
51 (void)v;
52}
53
54void pointer_cb(void* data EINA_UNUSED, void* value)
55{
56 struct value_type* p = value;
57 volatile int v = p->x * p->y * p->w * p->h;
58 (void)v;
59}
60
61static void
62eina_bench_promise_sync_then(int request)
63{
64 const char *tmp;
65 unsigned int j;
66 int i;
67
68 eina_init();
69
70 Eina_Promise_Owner* owner = eina_promise_add();
71 Eina_Promise* promise = eina_promise_owner_promise_get(owner);
72 eina_promise_ref(promise);
73
74 struct value_type v = { 0, 0, 0, 0 };
75 eina_promise_owner_value_set(owner, &v, NULL);
76
77 for (j = 0; j != 200; ++j)
78 for (i = 0; i != request; ++i)
79 {
80 eina_promise_then(promise, &cb, NULL, NULL);
81 }
82
83 /* Suppress warnings as we really don't want to do anything. */
84 (void) tmp;
85
86 eina_promise_unref(promise);
87 eina_shutdown();
88}
89
90static void indirect_free(void* p)
91{
92 free(p);
93}
94
95static void
96eina_bench_promise_pointer_value_set_before_then(int request)
97{
98 const char *tmp;
99 unsigned int j;
100 int i;
101
102 eina_init();
103
104 for (j = 0; j != 200; ++j)
105 for (i = 0; i != request; ++i)
106 {
107 Eina_Promise_Owner* owner = eina_promise_add();
108 Eina_Promise* promise = eina_promise_owner_promise_get(owner);
109
110 struct value_type* p = malloc(sizeof(struct value_type));
111 p->x = p->y = p->w = p->h = 0;
112
113 eina_promise_then(promise, &pointer_cb, NULL, NULL);
114 eina_promise_owner_value_set(owner, p, &indirect_free);
115 }
116
117 /* Suppress warnings as we really don't want to do anything. */
118 (void) tmp;
119
120 eina_shutdown();
121}
122
123static void
124eina_bench_promise_pointer_value_set_after_then(int request)
125{
126 const char *tmp;
127 unsigned int j;
128 int i;
129
130 eina_init();
131
132 for (j = 0; j != 200; ++j)
133 for (i = 0; i != request; ++i)
134 {
135 Eina_Promise_Owner* owner = eina_promise_add();
136 Eina_Promise* promise = eina_promise_owner_promise_get(owner);
137
138 struct value_type* p = malloc(sizeof(struct value_type));
139 p->x = p->y = p->w = p->h = 0;
140
141 eina_promise_owner_value_set(owner, p, &indirect_free);
142 eina_promise_then(promise, &pointer_cb, NULL, NULL);
143 }
144
145 /* Suppress warnings as we really don't want to do anything. */
146 (void) tmp;
147
148 eina_shutdown();
149}
150
151static Eina_Mempool* mempool;
152
153static void indirect_mempool_free(void* p)
154{
155 eina_mempool_free(mempool, *(void**)p);
156}
157
158static void
159eina_bench_promise_pointer_value_set_before_then_pooled(int request)
160{
161 const char *tmp;
162 unsigned int j;
163 int i;
164
165 eina_init();
166
167 mempool = eina_mempool_add("chained_mempool", "", NULL, sizeof(struct value_type), 10);
168 assert(mempool != NULL);
169
170 for (j = 0; j != 200; ++j)
171 for (i = 0; i != request; ++i)
172 {
173 Eina_Promise_Owner* owner = eina_promise_add();
174 Eina_Promise* promise = eina_promise_owner_promise_get(owner);
175
176 struct value_type* p = eina_mempool_malloc(mempool, sizeof(struct value_type));
177 p->x = p->y = p->w = p->h = 0;
178
179 eina_promise_then(promise, &pointer_cb, NULL, NULL);
180 eina_promise_owner_value_set(owner, p, &indirect_mempool_free);
181 }
182
183 /* Suppress warnings as we really don't want to do anything. */
184 (void) tmp;
185
186 eina_mempool_del(mempool);
187
188 eina_shutdown();
189}
190
191static void
192eina_bench_promise_pointer_value_set_after_then_pooled(int request)
193{
194 const char *tmp;
195 unsigned int j;
196 int i;
197
198 eina_init();
199
200 mempool = eina_mempool_add("chained_mempool", "", NULL, sizeof(struct value_type), 10);
201 assert(mempool != NULL);
202
203 for (j = 0; j != 200; ++j)
204 for (i = 0; i != request; ++i)
205 {
206 Eina_Promise_Owner* owner = eina_promise_add();
207 Eina_Promise* promise = eina_promise_owner_promise_get(owner);
208
209 struct value_type* p = eina_mempool_malloc(mempool, sizeof(struct value_type));
210 p->x = p->y = p->w = p->h = 0;
211
212 eina_promise_owner_value_set(owner, p, &indirect_mempool_free);
213 eina_promise_then(promise, &pointer_cb, NULL, NULL);
214 }
215
216 /* Suppress warnings as we really don't want to do anything. */
217 (void) tmp;
218
219 eina_mempool_del(mempool);
220 eina_shutdown();
221}
222
223static void
224eina_bench_promise_pointer_value_set_before_then_non_alloc(int request)
225{
226 const char *tmp;
227 unsigned int j;
228 int i;
229
230 eina_init();
231
232 mempool = eina_mempool_add("chained_mempool", "", NULL, sizeof(struct value_type), 10);
233 assert(mempool != NULL);
234
235 for (j = 0; j != 200; ++j)
236 for (i = 0; i != request; ++i)
237 {
238 Eina_Promise_Owner* owner = eina_promise_add();
239 Eina_Promise* promise = eina_promise_owner_promise_get(owner);
240
241 struct value_type v = {0,0,0,0};
242
243 eina_promise_then(promise, &pointer_cb, NULL, NULL);
244 eina_promise_owner_value_set(owner, &v, NULL);
245 }
246
247 /* Suppress warnings as we really don't want to do anything. */
248 (void) tmp;
249
250 eina_mempool_del(mempool);
251
252 eina_shutdown();
253}
254
255static void
256eina_bench_promise_pointer_value_set_after_then_non_alloc(int request)
257{
258 const char *tmp;
259 unsigned int j;
260 int i;
261
262 eina_init();
263
264 mempool = eina_mempool_add("chained_mempool", "", NULL, sizeof(struct value_type), 10);
265 assert(mempool != NULL);
266
267 for (j = 0; j != 200; ++j)
268 for (i = 0; i != request; ++i)
269 {
270 Eina_Promise_Owner* owner = eina_promise_add();
271 Eina_Promise* promise = eina_promise_owner_promise_get(owner);
272
273 struct value_type v = {0,0,0,0};
274
275 eina_promise_owner_value_set(owner, &v, NULL);
276 eina_promise_then(promise, &pointer_cb, NULL, NULL);
277 }
278
279 /* Suppress warnings as we really don't want to do anything. */
280 (void) tmp;
281
282 eina_mempool_del(mempool);
283 eina_shutdown();
284}
285
286void eina_bench_promise(Eina_Benchmark *bench)
287{
288 eina_benchmark_register(bench, "promise synchronous then",
289 EINA_BENCHMARK(
290 eina_bench_promise_sync_then), 100, 20100, 500);
291 eina_benchmark_register(bench, "promise pointer value set after then mempool",
292 EINA_BENCHMARK(
293 eina_bench_promise_pointer_value_set_after_then_pooled), 100, 20100, 500);
294 eina_benchmark_register(bench, "promise pointer value set before then mempool",
295 EINA_BENCHMARK(
296 eina_bench_promise_pointer_value_set_before_then_pooled), 100, 20100, 500);
297 eina_benchmark_register(bench, "promise pointer value set after then",
298 EINA_BENCHMARK(
299 eina_bench_promise_pointer_value_set_after_then), 100, 20100, 500);
300 eina_benchmark_register(bench, "promise pointer value set before then",
301 EINA_BENCHMARK(
302 eina_bench_promise_pointer_value_set_before_then), 100, 20100, 500);
303 eina_benchmark_register(bench, "promise pointer value set after then non alloc",
304 EINA_BENCHMARK(
305 eina_bench_promise_pointer_value_set_after_then_non_alloc), 100, 20100, 500);
306 eina_benchmark_register(bench, "promise pointer value set before then non alloc",
307 EINA_BENCHMARK(
308 eina_bench_promise_pointer_value_set_before_then_non_alloc), 100, 20100, 500);
309}