summaryrefslogtreecommitdiff
path: root/src/benchmarks/eo
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2015-10-14 15:03:33 +0100
committerTom Hacohen <tom@stosb.com>2015-11-09 11:43:04 +0000
commit4bf0f6455d3b7df37c922fb011a0fa9c6cc12fe2 (patch)
tree34f36dd856ef578544a081c193e9f60804f04641 /src/benchmarks/eo
parent862372ed2316d23e657f3562a4d5c77d05bd8849 (diff)
Eo benchmarks: Add basic callbacks benchmarks.
Diffstat (limited to 'src/benchmarks/eo')
-rw-r--r--src/benchmarks/eo/Makefile.am1
-rw-r--r--src/benchmarks/eo/class_simple.c3
-rw-r--r--src/benchmarks/eo/class_simple.h6
-rw-r--r--src/benchmarks/eo/eo_bench.c1
-rw-r--r--src/benchmarks/eo/eo_bench.h1
-rw-r--r--src/benchmarks/eo/eo_bench_callbacks.c85
6 files changed, 97 insertions, 0 deletions
diff --git a/src/benchmarks/eo/Makefile.am b/src/benchmarks/eo/Makefile.am
index 84d55b0e16..9fa4c1ee6e 100644
--- a/src/benchmarks/eo/Makefile.am
+++ b/src/benchmarks/eo/Makefile.am
@@ -18,6 +18,7 @@ class_simple.c \
18class_simple.h \ 18class_simple.h \
19eo_bench.c \ 19eo_bench.c \
20eo_bench.h \ 20eo_bench.h \
21eo_bench_callbacks.c \
21eo_bench_eo_do.c \ 22eo_bench_eo_do.c \
22eo_bench_eo_add.c 23eo_bench_eo_add.c
23 24
diff --git a/src/benchmarks/eo/class_simple.c b/src/benchmarks/eo/class_simple.c
index 7ff15db595..0a57e285fa 100644
--- a/src/benchmarks/eo/class_simple.c
+++ b/src/benchmarks/eo/class_simple.c
@@ -7,6 +7,9 @@
7 7
8#define MY_CLASS SIMPLE_CLASS 8#define MY_CLASS SIMPLE_CLASS
9 9
10EOAPI const Eo_Event_Description _SIMPLE_FOO = EO_EVENT_DESCRIPTION("foo");
11EOAPI const Eo_Event_Description _SIMPLE_BAR = EO_EVENT_DESCRIPTION("bar");
12
10static void 13static void
11_other_call(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED, Eo *other, int times) 14_other_call(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED, Eo *other, int times)
12{ 15{
diff --git a/src/benchmarks/eo/class_simple.h b/src/benchmarks/eo/class_simple.h
index 1d78188fe1..6460b0a5f5 100644
--- a/src/benchmarks/eo/class_simple.h
+++ b/src/benchmarks/eo/class_simple.h
@@ -14,4 +14,10 @@ EAPI void simple_other_call(Eo *other, int times);
14#define SIMPLE_CLASS simple_class_get() 14#define SIMPLE_CLASS simple_class_get()
15const Eo_Class *simple_class_get(void); 15const Eo_Class *simple_class_get(void);
16 16
17EOAPI extern const Eo_Event_Description _SIMPLE_FOO;
18EOAPI extern const Eo_Event_Description _SIMPLE_BAR;
19
20#define SIMPLE_FOO (&(_SIMPLE_FOO))
21#define SIMPLE_BAR (&(_SIMPLE_BAR))
22
17#endif 23#endif
diff --git a/src/benchmarks/eo/eo_bench.c b/src/benchmarks/eo/eo_bench.c
index 9266e6efe2..3b6584e2b1 100644
--- a/src/benchmarks/eo/eo_bench.c
+++ b/src/benchmarks/eo/eo_bench.c
@@ -21,6 +21,7 @@ struct _Eina_Benchmark_Case
21static const Eina_Benchmark_Case etc[] = { 21static const Eina_Benchmark_Case etc[] = {
22 { "eo_do", eo_bench_eo_do }, 22 { "eo_do", eo_bench_eo_do },
23 { "eo_add", eo_bench_eo_add }, 23 { "eo_add", eo_bench_eo_add },
24 { "eo_callbacks", eo_bench_callbacks },
24 { NULL, NULL } 25 { NULL, NULL }
25}; 26};
26 27
diff --git a/src/benchmarks/eo/eo_bench.h b/src/benchmarks/eo/eo_bench.h
index 9e3e80d82f..88ee999d69 100644
--- a/src/benchmarks/eo/eo_bench.h
+++ b/src/benchmarks/eo/eo_bench.h
@@ -3,6 +3,7 @@
3 3
4void eo_bench_eo_do(Eina_Benchmark *bench); 4void eo_bench_eo_do(Eina_Benchmark *bench);
5void eo_bench_eo_add(Eina_Benchmark *bench); 5void eo_bench_eo_add(Eina_Benchmark *bench);
6void eo_bench_callbacks(Eina_Benchmark *bench);
6 7
7#define _EO_BENCH_TIMES(Start, Repeat, Jump) (Start), ((Start) + ((Jump) * (Repeat))), (Jump) 8#define _EO_BENCH_TIMES(Start, Repeat, Jump) (Start), ((Start) + ((Jump) * (Repeat))), (Jump)
8 9
diff --git a/src/benchmarks/eo/eo_bench_callbacks.c b/src/benchmarks/eo/eo_bench_callbacks.c
new file mode 100644
index 0000000000..fde611eea1
--- /dev/null
+++ b/src/benchmarks/eo/eo_bench_callbacks.c
@@ -0,0 +1,85 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "eo_bench.h"
7#include "class_simple.h"
8
9static Eina_Bool
10_cb(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
11{
12 return EO_CALLBACK_CONTINUE;
13}
14
15
16static void
17bench_eo_callbacks_add(int request)
18{
19 int i;
20 Eo *obj = eo_add(SIMPLE_CLASS, NULL);
21
22 for (i = 0 ; i < request ; i++)
23 {
24 eo_do(obj, eo_event_callback_priority_add(SIMPLE_FOO, (short) i, _cb, NULL));
25 }
26
27 eo_unref(obj);
28}
29
30static void
31bench_eo_callbacks_call(int request)
32{
33 /* Distribution of calls per amount of callbacks in an object as recorded by
34 running the genlist elementary_test test. */
35 const double distribution[] = {
36 0.2920468197,
37 0.2073086496,
38 0.217699456,
39 0.0207158285,
40 0.019707134,
41 0.0359433565,
42 0.0324896742,
43 0.0104299639,
44 0.028989003,
45 0.0082496801,
46 0.123214227,
47 0.0001331351,
48 0.0030730724
49 };
50
51 const int len = EINA_C_ARRAY_LENGTH(distribution);
52 int i, j;
53 Eo *obj[len] = { 0 };
54 for (i = 0 ; i < len ; i++)
55 {
56 obj[i] = eo_add(SIMPLE_CLASS, NULL);
57
58 for (j = 0 ; j < i ; j++)
59 {
60 eo_do(obj[i], eo_event_callback_priority_add(SIMPLE_FOO, (short) j, _cb, NULL));
61 }
62 }
63
64 for (i = 0 ; i < len ; i++)
65 {
66 for (j = 0 ; j < (int) (distribution[i] * request) ; j++)
67 {
68 /* Miss finding the callbacks on purpose, so we measure worst case scenario. */
69 eo_do(obj[i], eo_event_callback_call(SIMPLE_BAR, NULL));
70 }
71 }
72
73 for (i = 0 ; i < len ; i++)
74 {
75 eo_unref(obj[i]);
76 }
77}
78
79void eo_bench_callbacks(Eina_Benchmark *bench)
80{
81 eina_benchmark_register(bench, "add",
82 EINA_BENCHMARK(bench_eo_callbacks_add), _EO_BENCH_TIMES(1000, 10, 2000));
83 eina_benchmark_register(bench, "call",
84 EINA_BENCHMARK(bench_eo_callbacks_call), _EO_BENCH_TIMES(100000, 10, 500000));
85}