summaryrefslogtreecommitdiff
path: root/legacy
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2012-08-26 13:18:44 +0000
committerTom Hacohen <tom@stosb.com>2012-08-26 13:18:44 +0000
commite8ad8e3a93772027ca83a744650c28dc9ec535e1 (patch)
tree3d18cb0100b84499dc0c935ef46eaeb2fbfb7b2f /legacy
parent4c7a23d21e27e7e6b6721842b693567b6a876eb9 (diff)
Eo: Added simple benchmark infra (not really testing anything atm).
SVN revision: 75712
Diffstat (limited to 'legacy')
-rw-r--r--legacy/eobj/CMakeLists.txt1
-rw-r--r--legacy/eobj/src/benchmarks/CMakeLists.txt26
-rw-r--r--legacy/eobj/src/benchmarks/class_simple.c48
-rw-r--r--legacy/eobj/src/benchmarks/class_simple.h25
-rw-r--r--legacy/eobj/src/benchmarks/eo_bench.c53
-rw-r--r--legacy/eobj/src/benchmarks/eo_bench.h9
-rw-r--r--legacy/eobj/src/benchmarks/eo_bench_eo_do.c27
7 files changed, 189 insertions, 0 deletions
diff --git a/legacy/eobj/CMakeLists.txt b/legacy/eobj/CMakeLists.txt
index a466c6485e..8742a797b2 100644
--- a/legacy/eobj/CMakeLists.txt
+++ b/legacy/eobj/CMakeLists.txt
@@ -41,6 +41,7 @@ include(EFLCheck)
41add_subdirectory(src/lib) 41add_subdirectory(src/lib)
42 42
43add_subdirectory(src/tests EXCLUDE_FROM_ALL) 43add_subdirectory(src/tests EXCLUDE_FROM_ALL)
44add_subdirectory(src/benchmarks EXCLUDE_FROM_ALL)
44add_subdirectory(src/examples) 45add_subdirectory(src/examples)
45 46
46add_subdirectory(doc) 47add_subdirectory(doc)
diff --git a/legacy/eobj/src/benchmarks/CMakeLists.txt b/legacy/eobj/src/benchmarks/CMakeLists.txt
new file mode 100644
index 0000000000..84529d91fa
--- /dev/null
+++ b/legacy/eobj/src/benchmarks/CMakeLists.txt
@@ -0,0 +1,26 @@
1LIST(APPEND EO_SUITE_CC_SOURCES
2 eo_bench.c
3 eo_bench_eo_do.c
4 class_simple.c
5 )
6
7add_executable(eo_bench ${EO_SUITE_CC_SOURCES})
8
9include_directories(
10 ${EINA_INCLUDE_DIRS}
11 ${CMAKE_SOURCE_DIR}/src/lib
12 )
13
14get_target_property(eo_LIB_FILE eo LOCATION)
15target_link_libraries(eo_bench
16 ${EINA_LIBRARIES}
17 ${EINA_LDFLAGS_OTHER}
18 ${eo_LIB_FILE}
19 )
20
21add_dependencies(eo_bench eo)
22
23get_target_property(eo_bench_EXEC_FILE eo_bench LOCATION)
24add_custom_target(benchmark COMMAND ${eo_bench_EXEC_FILE} eo_bench)
25
26add_dependencies(benchmark eo_bench)
diff --git a/legacy/eobj/src/benchmarks/class_simple.c b/legacy/eobj/src/benchmarks/class_simple.c
new file mode 100644
index 0000000000..6492d91b62
--- /dev/null
+++ b/legacy/eobj/src/benchmarks/class_simple.c
@@ -0,0 +1,48 @@
1#include "Eo.h"
2#include "class_simple.h"
3
4#include "config.h"
5
6#define MY_CLASS SIMPLE_CLASS
7
8EAPI Eo_Op SIMPLE_BASE_ID = 0;
9
10static void
11_a_set(Eo *obj EINA_UNUSED, void *class_data, va_list *list)
12{
13 Simple_Public_Data *pd = class_data;
14 int a;
15 a = va_arg(*list, int);
16
17 pd->a = a;
18}
19
20static void
21_class_constructor(Eo_Class *klass)
22{
23 const Eo_Op_Func_Description func_desc[] = {
24 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
25 EO_OP_FUNC_SENTINEL
26 };
27
28 eo_class_funcs_set(klass, func_desc);
29}
30
31static const Eo_Op_Description op_desc[] = {
32 EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "Set property A"),
33 EO_OP_DESCRIPTION_SENTINEL
34};
35
36static const Eo_Class_Description class_desc = {
37 EO_VERSION,
38 "Simple",
39 EO_CLASS_TYPE_REGULAR,
40 EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
41 NULL,
42 sizeof(Simple_Public_Data),
43 _class_constructor,
44 NULL
45};
46
47EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL)
48
diff --git a/legacy/eobj/src/benchmarks/class_simple.h b/legacy/eobj/src/benchmarks/class_simple.h
new file mode 100644
index 0000000000..86f07a1c07
--- /dev/null
+++ b/legacy/eobj/src/benchmarks/class_simple.h
@@ -0,0 +1,25 @@
1#ifndef SIMPLE_H
2#define SIMPLE_H
3
4#include "Eo.h"
5
6extern EAPI Eo_Op SIMPLE_BASE_ID;
7
8enum {
9 SIMPLE_SUB_ID_A_SET,
10 SIMPLE_SUB_ID_LAST
11};
12
13typedef struct
14{
15 int a;
16} Simple_Public_Data;
17
18#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id)
19
20#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_TYPECHECK(int, a)
21
22#define SIMPLE_CLASS simple_class_get()
23const Eo_Class *simple_class_get(void);
24
25#endif
diff --git a/legacy/eobj/src/benchmarks/eo_bench.c b/legacy/eobj/src/benchmarks/eo_bench.c
new file mode 100644
index 0000000000..580f744f1a
--- /dev/null
+++ b/legacy/eobj/src/benchmarks/eo_bench.c
@@ -0,0 +1,53 @@
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 "Eo.h"
10#include "eo_bench.h"
11
12typedef struct _Eina_Benchmark_Case Eina_Benchmark_Case;
13struct _Eina_Benchmark_Case
14{
15 const char *bench_case;
16 void (*build)(Eina_Benchmark *bench);
17};
18
19static const Eina_Benchmark_Case etc[] = {
20 { "Eo_Do", eo_bench_eo_do },
21 { NULL, NULL }
22};
23
24int
25main(int argc, char **argv)
26{
27 Eina_Benchmark *test;
28 unsigned int i;
29
30 if (argc != 2)
31 return -1;
32
33 eina_init();
34 eo_init();
35
36 for (i = 0; etc[i].bench_case; ++i)
37 {
38 test = eina_benchmark_new(etc[i].bench_case, argv[1]);
39 if (!test)
40 continue;
41
42 etc[i].build(test);
43
44 eina_benchmark_run(test);
45
46 eina_benchmark_free(test);
47 }
48
49 eo_shutdown();
50 eina_shutdown();
51
52 return 0;
53}
diff --git a/legacy/eobj/src/benchmarks/eo_bench.h b/legacy/eobj/src/benchmarks/eo_bench.h
new file mode 100644
index 0000000000..f55f1c3e58
--- /dev/null
+++ b/legacy/eobj/src/benchmarks/eo_bench.h
@@ -0,0 +1,9 @@
1#ifndef EINA_BENCH_H_
2#define EINA_BENCH_H_
3
4#include <Eina.h>
5#include <eina_benchmark.h>
6
7void eo_bench_eo_do(Eina_Benchmark *bench);
8
9#endif
diff --git a/legacy/eobj/src/benchmarks/eo_bench_eo_do.c b/legacy/eobj/src/benchmarks/eo_bench_eo_do.c
new file mode 100644
index 0000000000..2b1991fa14
--- /dev/null
+++ b/legacy/eobj/src/benchmarks/eo_bench_eo_do.c
@@ -0,0 +1,27 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include "Eo.h"
6#include "eo_bench.h"
7
8#include "class_simple.h"
9
10static void
11bench_eo_do_general(int request)
12{
13 int i;
14 Eo *obj = eo_add(SIMPLE_CLASS, NULL);
15 for (i = 0 ; i < request ; i++)
16 {
17 eo_do(obj, simple_a_set(i));
18 }
19
20 eo_unref(obj);
21}
22
23void eo_bench_eo_do(Eina_Benchmark *bench)
24{
25 eina_benchmark_register(bench, "general",
26 EINA_BENCHMARK(bench_eo_do_general), 100, 10000, 500);
27}