aboutsummaryrefslogtreecommitdiffstats
path: root/src/benchmarks
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
parentEo benchmarks: Improve benchmarks. (diff)
downloadefl-4bf0f6455d3b7df37c922fb011a0fa9c6cc12fe2.tar.gz
Eo benchmarks: Add basic callbacks benchmarks.
Diffstat (limited to 'src/benchmarks')
-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 \
class_simple.h \
eo_bench.c \
eo_bench.h \
+eo_bench_callbacks.c \
eo_bench_eo_do.c \
eo_bench_eo_add.c
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 @@
#define MY_CLASS SIMPLE_CLASS
+EOAPI const Eo_Event_Description _SIMPLE_FOO = EO_EVENT_DESCRIPTION("foo");
+EOAPI const Eo_Event_Description _SIMPLE_BAR = EO_EVENT_DESCRIPTION("bar");
+
static void
_other_call(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED, Eo *other, int times)
{
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);
#define SIMPLE_CLASS simple_class_get()
const Eo_Class *simple_class_get(void);
+EOAPI extern const Eo_Event_Description _SIMPLE_FOO;
+EOAPI extern const Eo_Event_Description _SIMPLE_BAR;
+
+#define SIMPLE_FOO (&(_SIMPLE_FOO))
+#define SIMPLE_BAR (&(_SIMPLE_BAR))
+
#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
static const Eina_Benchmark_Case etc[] = {
{ "eo_do", eo_bench_eo_do },
{ "eo_add", eo_bench_eo_add },
+ { "eo_callbacks", eo_bench_callbacks },
{ NULL, NULL }
};
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 @@
void eo_bench_eo_do(Eina_Benchmark *bench);
void eo_bench_eo_add(Eina_Benchmark *bench);
+void eo_bench_callbacks(Eina_Benchmark *bench);
#define _EO_BENCH_TIMES(Start, Repeat, Jump) (Start), ((Start) + ((Jump) * (Repeat))), (Jump)
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 @@
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "Eo.h"
+#include "eo_bench.h"
+#include "class_simple.h"
+
+static Eina_Bool
+_cb(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+ return EO_CALLBACK_CONTINUE;
+}
+
+
+static void
+bench_eo_callbacks_add(int request)
+{
+ int i;
+ Eo *obj = eo_add(SIMPLE_CLASS, NULL);
+
+ for (i = 0 ; i < request ; i++)
+ {
+ eo_do(obj, eo_event_callback_priority_add(SIMPLE_FOO, (short) i, _cb, NULL));
+ }
+
+ eo_unref(obj);
+}
+
+static void
+bench_eo_callbacks_call(int request)
+{
+ /* Distribution of calls per amount of callbacks in an object as recorded by
+ running the genlist elementary_test test. */
+ const double distribution[] = {
+ 0.2920468197,
+ 0.2073086496,
+ 0.217699456,
+ 0.0207158285,
+ 0.019707134,
+ 0.0359433565,
+ 0.0324896742,
+ 0.0104299639,
+ 0.028989003,
+ 0.0082496801,
+ 0.123214227,
+ 0.0001331351,
+ 0.0030730724
+ };
+
+ const int len = EINA_C_ARRAY_LENGTH(distribution);
+ int i, j;
+ Eo *obj[len] = { 0 };
+ for (i = 0 ; i < len ; i++)
+ {
+ obj[i] = eo_add(SIMPLE_CLASS, NULL);
+
+ for (j = 0 ; j < i ; j++)
+ {
+ eo_do(obj[i], eo_event_callback_priority_add(SIMPLE_FOO, (short) j, _cb, NULL));
+ }
+ }
+
+ for (i = 0 ; i < len ; i++)
+ {
+ for (j = 0 ; j < (int) (distribution[i] * request) ; j++)
+ {
+ /* Miss finding the callbacks on purpose, so we measure worst case scenario. */
+ eo_do(obj[i], eo_event_callback_call(SIMPLE_BAR, NULL));
+ }
+ }
+
+ for (i = 0 ; i < len ; i++)
+ {
+ eo_unref(obj[i]);
+ }
+}
+
+void eo_bench_callbacks(Eina_Benchmark *bench)
+{
+ eina_benchmark_register(bench, "add",
+ EINA_BENCHMARK(bench_eo_callbacks_add), _EO_BENCH_TIMES(1000, 10, 2000));
+ eina_benchmark_register(bench, "call",
+ EINA_BENCHMARK(bench_eo_callbacks_call), _EO_BENCH_TIMES(100000, 10, 500000));
+}