summaryrefslogtreecommitdiff
path: root/src/benchmarks
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2012-09-26 06:56:52 +0000
committerVincent Torri <vincent.torri@gmail.com>2012-09-26 06:56:52 +0000
commit3b5a3448b7dfc53c2f129bdb04bea9f7a02741a6 (patch)
tree18ad8a6b1841e9832c85a46f887b2cd6d6dacc4b /src/benchmarks
parent195d31c73fef88cfaa803b07b2ae3cba983a4093 (diff)
merge: add eo
SVN revision: 77072
Diffstat (limited to 'src/benchmarks')
-rw-r--r--src/benchmarks/Makefile.am5
-rw-r--r--src/benchmarks/eo/Makefile.am29
-rw-r--r--src/benchmarks/eo/class_simple.c50
-rw-r--r--src/benchmarks/eo/class_simple.h23
-rw-r--r--src/benchmarks/eo/eo_bench.c55
-rw-r--r--src/benchmarks/eo/eo_bench.h6
-rw-r--r--src/benchmarks/eo/eo_bench_eo_do.c26
7 files changed, 193 insertions, 1 deletions
diff --git a/src/benchmarks/Makefile.am b/src/benchmarks/Makefile.am
index b16aab1fd7..15fa26cece 100644
--- a/src/benchmarks/Makefile.am
+++ b/src/benchmarks/Makefile.am
@@ -1,11 +1,14 @@
1MAINTAINERCLEANFILES = Makefile.in 1MAINTAINERCLEANFILES = Makefile.in
2 2
3SUBDIRS = eina 3SUBDIRS = eina eo
4 4
5.PHONY: benchmark benchmark-e17 5.PHONY: benchmark benchmark-e17
6 6
7benchmark: 7benchmark:
8 @$(MAKE) $(AM_MAKEFLAGS) -C eina benchmark 8 @$(MAKE) $(AM_MAKEFLAGS) -C eina benchmark
9if EFL_BUILD_EO
10 @$(MAKE) $(AM_MAKEFLAGS) -C eo benchmark
11endif
9 12
10benchmark-e17: 13benchmark-e17:
11 @$(MAKE) $(AM_MAKEFLAGS) -C eina benchmark-e17 14 @$(MAKE) $(AM_MAKEFLAGS) -C eina benchmark-e17
diff --git a/src/benchmarks/eo/Makefile.am b/src/benchmarks/eo/Makefile.am
new file mode 100644
index 0000000000..e0f9e4c0f3
--- /dev/null
+++ b/src/benchmarks/eo/Makefile.am
@@ -0,0 +1,29 @@
1
2MAINTAINERCLEANFILES = Makefile.in
3
4AM_CPPFLAGS = \
5-I$(top_srcdir)/src/include/eina \
6-I$(top_srcdir)/src/lib/eo \
7-I$(top_builddir)/src/include/eina \
8-I$(top_builddir)/src/lib/eo \
9@EFL_EO_BUILD@ \
10@EO_CFLAGS@
11
12EXTRA_PROGRAMS = eo_bench
13
14benchmark: eo_bench
15
16eo_bench_SOURCES = \
17class_simple.c \
18class_simple.h \
19eo_bench.c \
20eo_bench.h \
21eo_bench_eo_do.c
22
23eo_bench_LDADD = \
24$(top_builddir)/src/lib/eo/libeo.la \
25$(top_builddir)/src/lib/eina/libeina.la \
26@EO_LIBS@
27
28clean-local:
29 rm -rf *.gcno ..\#..\#src\#*.gcov *.gcda
diff --git a/src/benchmarks/eo/class_simple.c b/src/benchmarks/eo/class_simple.c
new file mode 100644
index 0000000000..2e8dc3f621
--- /dev/null
+++ b/src/benchmarks/eo/class_simple.c
@@ -0,0 +1,50 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "class_simple.h"
7
8#define MY_CLASS SIMPLE_CLASS
9
10EAPI Eo_Op SIMPLE_BASE_ID = 0;
11
12static void
13_a_set(Eo *obj EINA_UNUSED, void *class_data, va_list *list)
14{
15 Simple_Public_Data *pd = class_data;
16 int a;
17 a = va_arg(*list, int);
18
19 pd->a = a;
20}
21
22static void
23_class_constructor(Eo_Class *klass)
24{
25 const Eo_Op_Func_Description func_desc[] = {
26 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
27 EO_OP_FUNC_SENTINEL
28 };
29
30 eo_class_funcs_set(klass, func_desc);
31}
32
33static const Eo_Op_Description op_desc[] = {
34 EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "Set property A"),
35 EO_OP_DESCRIPTION_SENTINEL
36};
37
38static const Eo_Class_Description class_desc = {
39 EO_VERSION,
40 "Simple",
41 EO_CLASS_TYPE_REGULAR,
42 EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
43 NULL,
44 sizeof(Simple_Public_Data),
45 _class_constructor,
46 NULL
47};
48
49EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL)
50
diff --git a/src/benchmarks/eo/class_simple.h b/src/benchmarks/eo/class_simple.h
new file mode 100644
index 0000000000..b29e7987c1
--- /dev/null
+++ b/src/benchmarks/eo/class_simple.h
@@ -0,0 +1,23 @@
1#ifndef SIMPLE_H
2#define SIMPLE_H
3
4extern EAPI Eo_Op SIMPLE_BASE_ID;
5
6enum {
7 SIMPLE_SUB_ID_A_SET,
8 SIMPLE_SUB_ID_LAST
9};
10
11typedef struct
12{
13 int a;
14} Simple_Public_Data;
15
16#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id)
17
18#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_TYPECHECK(int, a)
19
20#define SIMPLE_CLASS simple_class_get()
21const Eo_Class *simple_class_get(void);
22
23#endif
diff --git a/src/benchmarks/eo/eo_bench.c b/src/benchmarks/eo/eo_bench.c
new file mode 100644
index 0000000000..0da83a1f34
--- /dev/null
+++ b/src/benchmarks/eo/eo_bench.c
@@ -0,0 +1,55 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <stdlib.h>
6#include <stdio.h>
7#include <limits.h>
8
9#include <Eina.h>
10
11#include "Eo.h"
12#include "eo_bench.h"
13
14typedef struct _Eina_Benchmark_Case Eina_Benchmark_Case;
15struct _Eina_Benchmark_Case
16{
17 const char *bench_case;
18 void (*build)(Eina_Benchmark *bench);
19};
20
21static const Eina_Benchmark_Case etc[] = {
22 { "eo_do", eo_bench_eo_do },
23 { NULL, NULL }
24};
25
26int
27main(int argc, char **argv)
28{
29 Eina_Benchmark *test;
30 unsigned int i;
31
32 if (argc != 2)
33 return -1;
34
35 eina_init();
36 eo_init();
37
38 for (i = 0; etc[i].bench_case; ++i)
39 {
40 test = eina_benchmark_new(etc[i].bench_case, argv[1]);
41 if (!test)
42 continue;
43
44 etc[i].build(test);
45
46 eina_benchmark_run(test);
47
48 eina_benchmark_free(test);
49 }
50
51 eo_shutdown();
52 eina_shutdown();
53
54 return 0;
55}
diff --git a/src/benchmarks/eo/eo_bench.h b/src/benchmarks/eo/eo_bench.h
new file mode 100644
index 0000000000..feea3bc333
--- /dev/null
+++ b/src/benchmarks/eo/eo_bench.h
@@ -0,0 +1,6 @@
1#ifndef EINA_BENCH_H_
2#define EINA_BENCH_H_
3
4void eo_bench_eo_do(Eina_Benchmark *bench);
5
6#endif
diff --git a/src/benchmarks/eo/eo_bench_eo_do.c b/src/benchmarks/eo/eo_bench_eo_do.c
new file mode 100644
index 0000000000..1e8d484979
--- /dev/null
+++ b/src/benchmarks/eo/eo_bench_eo_do.c
@@ -0,0 +1,26 @@
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 void
10bench_eo_do_general(int request)
11{
12 int i;
13 Eo *obj = eo_add(SIMPLE_CLASS, NULL);
14 for (i = 0 ; i < request ; i++)
15 {
16 eo_do(obj, simple_a_set(i));
17 }
18
19 eo_unref(obj);
20}
21
22void eo_bench_eo_do(Eina_Benchmark *bench)
23{
24 eina_benchmark_register(bench, "various",
25 EINA_BENCHMARK(bench_eo_do_general), 100, 10000, 500);
26}