summaryrefslogtreecommitdiff
path: root/src/benchmarks/eina/eina_bench_promise.c
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2016-06-03 16:52:03 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2016-06-03 17:22:12 -0300
commit8fec0d5139a3ff30037ba159bb62ff2f733d96a8 (patch)
tree0316d756b8150e9ef40d76668e5084fdb06af29a /src/benchmarks/eina/eina_bench_promise.c
parent1dcccfdf8160ca6113d66c51c226302221b9a049 (diff)
eina: Remove unnecessary indirection to promises
Now when dealing with pointer types, we will not get pointer to pointer semantics in callbacks and eina_promise_owner_value_set for Eina_Promise. It will work as expected: Eina_Promise_Owner* promise = eina_promise_add(); void* p = malloc(sizeof(T)); eina_promise_owner_value_set(promise, p, &free);
Diffstat (limited to '')
-rw-r--r--src/benchmarks/eina/eina_bench_promise.c48
1 files changed, 21 insertions, 27 deletions
diff --git a/src/benchmarks/eina/eina_bench_promise.c b/src/benchmarks/eina/eina_bench_promise.c
index 0d1afc5d5d..ee6153ca22 100644
--- a/src/benchmarks/eina/eina_bench_promise.c
+++ b/src/benchmarks/eina/eina_bench_promise.c
@@ -67,7 +67,7 @@ eina_bench_promise_sync_then(int request)
67 67
68 eina_init(); 68 eina_init();
69 69
70 Eina_Promise_Owner* owner = eina_promise_default_add(sizeof(struct value_type)); 70 Eina_Promise_Owner* owner = eina_promise_value_add(sizeof(struct value_type));
71 Eina_Promise* promise = eina_promise_owner_promise_get(owner); 71 Eina_Promise* promise = eina_promise_owner_promise_get(owner);
72 eina_promise_ref(promise); 72 eina_promise_ref(promise);
73 73
@@ -101,7 +101,7 @@ eina_bench_promise_copy_value_set_after_then(int request)
101 for (j = 0; j != 200; ++j) 101 for (j = 0; j != 200; ++j)
102 for (i = 0; i != request; ++i) 102 for (i = 0; i != request; ++i)
103 { 103 {
104 Eina_Promise_Owner* owner = eina_promise_default_add(sizeof(struct value_type)); 104 Eina_Promise_Owner* owner = eina_promise_value_add(sizeof(struct value_type));
105 Eina_Promise* promise = eina_promise_owner_promise_get(owner); 105 Eina_Promise* promise = eina_promise_owner_promise_get(owner);
106 106
107 eina_promise_then(promise, &cb, NULL, NULL); 107 eina_promise_then(promise, &cb, NULL, NULL);
@@ -126,7 +126,7 @@ eina_bench_promise_no_copy_value_set_after_then(int request)
126 for (j = 0; j != 200; ++j) 126 for (j = 0; j != 200; ++j)
127 for (i = 0; i != request; ++i) 127 for (i = 0; i != request; ++i)
128 { 128 {
129 Eina_Promise_Owner* owner = eina_promise_default_add(sizeof(struct value_type)); 129 Eina_Promise_Owner* owner = eina_promise_value_add(sizeof(struct value_type));
130 Eina_Promise* promise = eina_promise_owner_promise_get(owner); 130 Eina_Promise* promise = eina_promise_owner_promise_get(owner);
131 struct value_type* v = eina_promise_owner_buffer_get(owner); 131 struct value_type* v = eina_promise_owner_buffer_get(owner);
132 132
@@ -154,7 +154,7 @@ eina_bench_promise_no_copy_value_set_before_then(int request)
154 for (j = 0; j != 200; ++j) 154 for (j = 0; j != 200; ++j)
155 for (i = 0; i != request; ++i) 155 for (i = 0; i != request; ++i)
156 { 156 {
157 Eina_Promise_Owner* owner = eina_promise_default_add(sizeof(struct value_type)); 157 Eina_Promise_Owner* owner = eina_promise_value_add(sizeof(struct value_type));
158 Eina_Promise* promise = eina_promise_owner_promise_get(owner); 158 Eina_Promise* promise = eina_promise_owner_promise_get(owner);
159 struct value_type* v = eina_promise_owner_buffer_get(owner); 159 struct value_type* v = eina_promise_owner_buffer_get(owner);
160 160
@@ -184,7 +184,7 @@ eina_bench_promise_copy_value_set_before_then(int request)
184 for (j = 0; j != 200; ++j) 184 for (j = 0; j != 200; ++j)
185 for (i = 0; i != request; ++i) 185 for (i = 0; i != request; ++i)
186 { 186 {
187 Eina_Promise_Owner* owner = eina_promise_default_add(sizeof(struct value_type)); 187 Eina_Promise_Owner* owner = eina_promise_value_add(sizeof(struct value_type));
188 Eina_Promise* promise = eina_promise_owner_promise_get(owner); 188 Eina_Promise* promise = eina_promise_owner_promise_get(owner);
189 189
190 eina_promise_then(promise, &cb, NULL, NULL); 190 eina_promise_then(promise, &cb, NULL, NULL);
@@ -214,15 +214,14 @@ eina_bench_promise_pointer_value_set_before_then(int request)
214 for (j = 0; j != 200; ++j) 214 for (j = 0; j != 200; ++j)
215 for (i = 0; i != request; ++i) 215 for (i = 0; i != request; ++i)
216 { 216 {
217 Eina_Promise_Owner* owner = eina_promise_default_add(sizeof(struct value_type*)); 217 Eina_Promise_Owner* owner = eina_promise_add();
218 Eina_Promise* promise = eina_promise_owner_promise_get(owner); 218 Eina_Promise* promise = eina_promise_owner_promise_get(owner);
219 219
220 struct value_type* p = *(struct value_type**)eina_promise_owner_buffer_get(owner) 220 struct value_type* p = malloc(sizeof(struct value_type));
221 = malloc(sizeof(struct value_type));
222 p->x = p->y = p->w = p->h = 0; 221 p->x = p->y = p->w = p->h = 0;
223 222
224 eina_promise_then(promise, &pointer_cb, NULL, NULL); 223 eina_promise_then(promise, &pointer_cb, NULL, NULL);
225 eina_promise_owner_value_set(owner, NULL, &indirect_free); 224 eina_promise_owner_value_set(owner, p, &indirect_free);
226 } 225 }
227 226
228 /* Suppress warnings as we really don't want to do anything. */ 227 /* Suppress warnings as we really don't want to do anything. */
@@ -243,14 +242,13 @@ eina_bench_promise_pointer_value_set_after_then(int request)
243 for (j = 0; j != 200; ++j) 242 for (j = 0; j != 200; ++j)
244 for (i = 0; i != request; ++i) 243 for (i = 0; i != request; ++i)
245 { 244 {
246 Eina_Promise_Owner* owner = eina_promise_default_add(sizeof(struct value_type*)); 245 Eina_Promise_Owner* owner = eina_promise_add();
247 Eina_Promise* promise = eina_promise_owner_promise_get(owner); 246 Eina_Promise* promise = eina_promise_owner_promise_get(owner);
248 247
249 struct value_type* p = *(struct value_type**)eina_promise_owner_buffer_get(owner) 248 struct value_type* p = malloc(sizeof(struct value_type));
250 = malloc(sizeof(struct value_type));
251 p->x = p->y = p->w = p->h = 0; 249 p->x = p->y = p->w = p->h = 0;
252 250
253 eina_promise_owner_value_set(owner, NULL, &indirect_free); 251 eina_promise_owner_value_set(owner, p, &indirect_free);
254 eina_promise_then(promise, &pointer_cb, NULL, NULL); 252 eina_promise_then(promise, &pointer_cb, NULL, NULL);
255 } 253 }
256 254
@@ -282,15 +280,14 @@ eina_bench_promise_pointer_value_set_before_then_pooled(int request)
282 for (j = 0; j != 200; ++j) 280 for (j = 0; j != 200; ++j)
283 for (i = 0; i != request; ++i) 281 for (i = 0; i != request; ++i)
284 { 282 {
285 Eina_Promise_Owner* owner = eina_promise_default_add(sizeof(struct value_type*)); 283 Eina_Promise_Owner* owner = eina_promise_add();
286 Eina_Promise* promise = eina_promise_owner_promise_get(owner); 284 Eina_Promise* promise = eina_promise_owner_promise_get(owner);
287 285
288 struct value_type* p = *(struct value_type**)eina_promise_owner_buffer_get(owner) 286 struct value_type* p = eina_mempool_malloc(mempool, sizeof(struct value_type));
289 = eina_mempool_malloc(mempool, sizeof(struct value_type));
290 p->x = p->y = p->w = p->h = 0; 287 p->x = p->y = p->w = p->h = 0;
291 288
292 eina_promise_then(promise, &pointer_cb, NULL, NULL); 289 eina_promise_then(promise, &pointer_cb, NULL, NULL);
293 eina_promise_owner_value_set(owner, NULL, &indirect_mempool_free); 290 eina_promise_owner_value_set(owner, p, &indirect_mempool_free);
294 } 291 }
295 292
296 /* Suppress warnings as we really don't want to do anything. */ 293 /* Suppress warnings as we really don't want to do anything. */
@@ -316,14 +313,13 @@ eina_bench_promise_pointer_value_set_after_then_pooled(int request)
316 for (j = 0; j != 200; ++j) 313 for (j = 0; j != 200; ++j)
317 for (i = 0; i != request; ++i) 314 for (i = 0; i != request; ++i)
318 { 315 {
319 Eina_Promise_Owner* owner = eina_promise_default_add(sizeof(struct value_type*)); 316 Eina_Promise_Owner* owner = eina_promise_add();
320 Eina_Promise* promise = eina_promise_owner_promise_get(owner); 317 Eina_Promise* promise = eina_promise_owner_promise_get(owner);
321 318
322 struct value_type* p = *(struct value_type**)eina_promise_owner_buffer_get(owner) 319 struct value_type* p = eina_mempool_malloc(mempool, sizeof(struct value_type));
323 = eina_mempool_malloc(mempool, sizeof(struct value_type));
324 p->x = p->y = p->w = p->h = 0; 320 p->x = p->y = p->w = p->h = 0;
325 321
326 eina_promise_owner_value_set(owner, NULL, &indirect_mempool_free); 322 eina_promise_owner_value_set(owner, p, &indirect_mempool_free);
327 eina_promise_then(promise, &pointer_cb, NULL, NULL); 323 eina_promise_then(promise, &pointer_cb, NULL, NULL);
328 } 324 }
329 325
@@ -349,14 +345,13 @@ eina_bench_promise_pointer_value_set_before_then_non_alloc(int request)
349 for (j = 0; j != 200; ++j) 345 for (j = 0; j != 200; ++j)
350 for (i = 0; i != request; ++i) 346 for (i = 0; i != request; ++i)
351 { 347 {
352 Eina_Promise_Owner* owner = eina_promise_default_add(sizeof(struct value_type*)); 348 Eina_Promise_Owner* owner = eina_promise_add();
353 Eina_Promise* promise = eina_promise_owner_promise_get(owner); 349 Eina_Promise* promise = eina_promise_owner_promise_get(owner);
354 350
355 struct value_type v = {0,0,0,0}; 351 struct value_type v = {0,0,0,0};
356 *(struct value_type**)eina_promise_owner_buffer_get(owner) = &v;
357 352
358 eina_promise_then(promise, &pointer_cb, NULL, NULL); 353 eina_promise_then(promise, &pointer_cb, NULL, NULL);
359 eina_promise_owner_value_set(owner, NULL, &indirect_mempool_free); 354 eina_promise_owner_value_set(owner, &v, NULL);
360 } 355 }
361 356
362 /* Suppress warnings as we really don't want to do anything. */ 357 /* Suppress warnings as we really don't want to do anything. */
@@ -382,13 +377,12 @@ eina_bench_promise_pointer_value_set_after_then_non_alloc(int request)
382 for (j = 0; j != 200; ++j) 377 for (j = 0; j != 200; ++j)
383 for (i = 0; i != request; ++i) 378 for (i = 0; i != request; ++i)
384 { 379 {
385 Eina_Promise_Owner* owner = eina_promise_default_add(sizeof(struct value_type*)); 380 Eina_Promise_Owner* owner = eina_promise_add();
386 Eina_Promise* promise = eina_promise_owner_promise_get(owner); 381 Eina_Promise* promise = eina_promise_owner_promise_get(owner);
387 382
388 struct value_type v = {0,0,0,0}; 383 struct value_type v = {0,0,0,0};
389 *(struct value_type**)eina_promise_owner_buffer_get(owner) = &v;
390 384
391 eina_promise_owner_value_set(owner, NULL, &indirect_mempool_free); 385 eina_promise_owner_value_set(owner, &v, NULL);
392 eina_promise_then(promise, &pointer_cb, NULL, NULL); 386 eina_promise_then(promise, &pointer_cb, NULL, NULL);
393 } 387 }
394 388