summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitor Sousa <vitorsousa@expertisesolutions.com.br>2019-05-21 17:24:33 -0300
committerVitor Sousa <vitorsousa@expertisesolutions.com.br>2019-05-21 17:26:54 -0300
commit713bbe7f5fdc4ed690a2da9f861940c3ed594742 (patch)
tree157b76762b8642ceaf8083db4ec628e48ee61476
parente33f444d8c298526219dddfd69182c806b5e6d6d (diff)
eo: benchmark for sharing (i.e. many refs) and them unsharing objects
-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 963cd3abb9..77f2eadb7f 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}