aboutsummaryrefslogtreecommitdiffstats
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
parentautotools: use DISTCLEAN rules to properly destroy files. (diff)
downloadefl-8fec0d5139a3ff30037ba159bb62ff2f733d96a8.tar.gz
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 'src/benchmarks/eina/eina_bench_promise.c')
-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)
eina_init();
- Eina_Promise_Owner* owner = eina_promise_default_add(sizeof(struct value_type));
+ Eina_Promise_Owner* owner = eina_promise_value_add(sizeof(struct value_type));
Eina_Promise* promise = eina_promise_owner_promise_get(owner);
eina_promise_ref(promise);
@@ -101,7 +101,7 @@ eina_bench_promise_copy_value_set_after_then(int request)
for (j = 0; j != 200; ++j)
for (i = 0; i != request; ++i)
{
- Eina_Promise_Owner* owner = eina_promise_default_add(sizeof(struct value_type));
+ Eina_Promise_Owner* owner = eina_promise_value_add(sizeof(struct value_type));
Eina_Promise* promise = eina_promise_owner_promise_get(owner);
eina_promise_then(promise, &cb, NULL, NULL);
@@ -126,7 +126,7 @@ eina_bench_promise_no_copy_value_set_after_then(int request)
for (j = 0; j != 200; ++j)
for (i = 0; i != request; ++i)
{
- Eina_Promise_Owner* owner = eina_promise_default_add(sizeof(struct value_type));
+ Eina_Promise_Owner* owner = eina_promise_value_add(sizeof(struct value_type));
Eina_Promise* promise = eina_promise_owner_promise_get(owner);
struct value_type* v = eina_promise_owner_buffer_get(owner);
@@ -154,7 +154,7 @@ eina_bench_promise_no_copy_value_set_before_then(int request)
for (j = 0; j != 200; ++j)
for (i = 0; i != request; ++i)
{
- Eina_Promise_Owner* owner = eina_promise_default_add(sizeof(struct value_type));
+ Eina_Promise_Owner* owner = eina_promise_value_add(sizeof(struct value_type));
Eina_Promise* promise = eina_promise_owner_promise_get(owner);
struct value_type* v = eina_promise_owner_buffer_get(owner);
@@ -184,7 +184,7 @@ eina_bench_promise_copy_value_set_before_then(int request)
for (j = 0; j != 200; ++j)
for (i = 0; i != request; ++i)
{
- Eina_Promise_Owner* owner = eina_promise_default_add(sizeof(struct value_type));
+ Eina_Promise_Owner* owner = eina_promise_value_add(sizeof(struct value_type));
Eina_Promise* promise = eina_promise_owner_promise_get(owner);
eina_promise_then(promise, &cb, NULL, NULL);
@@ -214,15 +214,14 @@ eina_bench_promise_pointer_value_set_before_then(int request)
for (j = 0; j != 200; ++j)
for (i = 0; i != request; ++i)
{
- Eina_Promise_Owner* owner = eina_promise_default_add(sizeof(struct value_type*));
+ Eina_Promise_Owner* owner = eina_promise_add();
Eina_Promise* promise = eina_promise_owner_promise_get(owner);
- struct value_type* p = *(struct value_type**)eina_promise_owner_buffer_get(owner)
- = malloc(sizeof(struct value_type));
+ struct value_type* p = malloc(sizeof(struct value_type));
p->x = p->y = p->w = p->h = 0;
eina_promise_then(promise, &pointer_cb, NULL, NULL);
- eina_promise_owner_value_set(owner, NULL, &indirect_free);
+ eina_promise_owner_value_set(owner, p, &indirect_free);
}
/* 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)
for (j = 0; j != 200; ++j)
for (i = 0; i != request; ++i)
{
- Eina_Promise_Owner* owner = eina_promise_default_add(sizeof(struct value_type*));
+ Eina_Promise_Owner* owner = eina_promise_add();
Eina_Promise* promise = eina_promise_owner_promise_get(owner);
- struct value_type* p = *(struct value_type**)eina_promise_owner_buffer_get(owner)
- = malloc(sizeof(struct value_type));
+ struct value_type* p = malloc(sizeof(struct value_type));
p->x = p->y = p->w = p->h = 0;
- eina_promise_owner_value_set(owner, NULL, &indirect_free);
+ eina_promise_owner_value_set(owner, p, &indirect_free);
eina_promise_then(promise, &pointer_cb, NULL, NULL);
}
@@ -282,15 +280,14 @@ eina_bench_promise_pointer_value_set_before_then_pooled(int request)
for (j = 0; j != 200; ++j)
for (i = 0; i != request; ++i)
{
- Eina_Promise_Owner* owner = eina_promise_default_add(sizeof(struct value_type*));
+ Eina_Promise_Owner* owner = eina_promise_add();
Eina_Promise* promise = eina_promise_owner_promise_get(owner);
- struct value_type* p = *(struct value_type**)eina_promise_owner_buffer_get(owner)
- = eina_mempool_malloc(mempool, sizeof(struct value_type));
+ struct value_type* p = eina_mempool_malloc(mempool, sizeof(struct value_type));
p->x = p->y = p->w = p->h = 0;
eina_promise_then(promise, &pointer_cb, NULL, NULL);
- eina_promise_owner_value_set(owner, NULL, &indirect_mempool_free);
+ eina_promise_owner_value_set(owner, p, &indirect_mempool_free);
}
/* 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)
for (j = 0; j != 200; ++j)
for (i = 0; i != request; ++i)
{
- Eina_Promise_Owner* owner = eina_promise_default_add(sizeof(struct value_type*));
+ Eina_Promise_Owner* owner = eina_promise_add();
Eina_Promise* promise = eina_promise_owner_promise_get(owner);
- struct value_type* p = *(struct value_type**)eina_promise_owner_buffer_get(owner)
- = eina_mempool_malloc(mempool, sizeof(struct value_type));
+ struct value_type* p = eina_mempool_malloc(mempool, sizeof(struct value_type));
p->x = p->y = p->w = p->h = 0;
- eina_promise_owner_value_set(owner, NULL, &indirect_mempool_free);
+ eina_promise_owner_value_set(owner, p, &indirect_mempool_free);
eina_promise_then(promise, &pointer_cb, NULL, NULL);
}
@@ -349,14 +345,13 @@ eina_bench_promise_pointer_value_set_before_then_non_alloc(int request)
for (j = 0; j != 200; ++j)
for (i = 0; i != request; ++i)
{
- Eina_Promise_Owner* owner = eina_promise_default_add(sizeof(struct value_type*));
+ Eina_Promise_Owner* owner = eina_promise_add();
Eina_Promise* promise = eina_promise_owner_promise_get(owner);
struct value_type v = {0,0,0,0};
- *(struct value_type**)eina_promise_owner_buffer_get(owner) = &v;
eina_promise_then(promise, &pointer_cb, NULL, NULL);
- eina_promise_owner_value_set(owner, NULL, &indirect_mempool_free);
+ eina_promise_owner_value_set(owner, &v, NULL);
}
/* 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)
for (j = 0; j != 200; ++j)
for (i = 0; i != request; ++i)
{
- Eina_Promise_Owner* owner = eina_promise_default_add(sizeof(struct value_type*));
+ Eina_Promise_Owner* owner = eina_promise_add();
Eina_Promise* promise = eina_promise_owner_promise_get(owner);
struct value_type v = {0,0,0,0};
- *(struct value_type**)eina_promise_owner_buffer_get(owner) = &v;
- eina_promise_owner_value_set(owner, NULL, &indirect_mempool_free);
+ eina_promise_owner_value_set(owner, &v, NULL);
eina_promise_then(promise, &pointer_cb, NULL, NULL);
}