summaryrefslogtreecommitdiff
path: root/src/benchmarks
diff options
context:
space:
mode:
authorVitor Sousa <vitorsousa@expertisesolutions.com.br>2019-05-23 18:41:57 +0000
committerCedric BAIL <cedric.bail@free.fr>2019-05-29 15:53:23 -0700
commita86a0931f16f6a9d5afbff71364048dc859e2dff (patch)
tree9412183d21dab63fb55e9157c95187b1cb46e571 /src/benchmarks
parent343698f7eceb7cc3cfdb21da955abd401adc16a8 (diff)
eo: add events to track the ownership status of an Eo object
Some user code may want to track an object ownership in regard to whether it is kept by just one owner or shared between many owners. This is specially true for code provided by bindings to other programming languages, where different kinds of resource management may take place. The event `ownership,unique` is triggered whenever the object refcount goes from two to one, as a signal that it has just one owner from now on. The event `ownership,shared` is triggered whenever the object refcount goes from one to two, as a signal that it has multiple owners from now on. It will not trigger when further increasing the refcount to any value beyond two. We also add benchmarks for sharing (i.e. increasing the refcount) and them unsharing objects, in order to evaluate the performance impact of this patch. Reviewed-by: Cedric BAIL <cedric.bail@free.fr> Differential Revision: https://phab.enlightenment.org/D8678
Diffstat (limited to 'src/benchmarks')
-rw-r--r--src/benchmarks/eo/eo_bench_eo_add.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/benchmarks/eo/eo_bench_eo_add.c b/src/benchmarks/eo/eo_bench_eo_add.c
index 963cd3a..77f2ead 100644
--- a/src/benchmarks/eo/eo_bench_eo_add.c
+++ b/src/benchmarks/eo/eo_bench_eo_add.c
@@ -38,10 +38,44 @@ bench_efl_add_jump_by_2(int request)
38 free(objs); 38 free(objs);
39} 39}
40 40
41static void
42bench_efl_add_shared_ownership(int request)
43{
44 int i;
45 Eo **objs = calloc(request, sizeof(Eo *));
46 Eo *p = efl_add_ref(SIMPLE_CLASS, NULL);
47 for (i = 0; i < request; i++)
48 objs[i] = efl_add_ref(SIMPLE_CLASS, p);
49 efl_unref(p);
50 for (i = 0; i < request; i++)
51 efl_unref(objs[i]);
52 free(objs);
53}
54
55static void
56bench_efl_add_shared_ownership_alternative(int request)
57{
58 int i;
59 Eo **objs = calloc(request, sizeof(Eo *));
60 Eo *p = efl_add_ref(SIMPLE_CLASS, NULL);
61 for (i = 0; i < request; i++)
62 objs[i] = efl_add(SIMPLE_CLASS, p);
63 for (i = 0; i < request; i++)
64 efl_ref(objs[i]);
65 for (i = 0; i < request; i++)
66 efl_unref(objs[i]);
67 efl_unref(p);
68 free(objs);
69}
70
41void eo_bench_efl_add(Eina_Benchmark *bench) 71void eo_bench_efl_add(Eina_Benchmark *bench)
42{ 72{
43 eina_benchmark_register(bench, "efl_add_linear", 73 eina_benchmark_register(bench, "efl_add_linear",
44 EINA_BENCHMARK(bench_efl_add_linear), _EO_BENCH_TIMES(1000, 10, 50000)); 74 EINA_BENCHMARK(bench_efl_add_linear), _EO_BENCH_TIMES(1000, 10, 50000));
45 eina_benchmark_register(bench, "efl_add_jump_by_2", 75 eina_benchmark_register(bench, "efl_add_jump_by_2",
46 EINA_BENCHMARK(bench_efl_add_jump_by_2), _EO_BENCH_TIMES(1000, 10, 50000)); 76 EINA_BENCHMARK(bench_efl_add_jump_by_2), _EO_BENCH_TIMES(1000, 10, 50000));
77 eina_benchmark_register(bench, "efl_add_shared_ownership",
78 EINA_BENCHMARK(bench_efl_add_shared_ownership), _EO_BENCH_TIMES(1000, 10, 50000));
79 eina_benchmark_register(bench, "efl_add_shared_ownership_alternative",
80 EINA_BENCHMARK(bench_efl_add_shared_ownership_alternative), _EO_BENCH_TIMES(1000, 10, 50000));
47} 81}