summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortasn <tasn>2012-08-26 13:18:44 +0000
committertasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>2012-08-26 13:18:44 +0000
commita8895a126992e5c5411513b5ef1a53dd2561b276 (patch)
tree490aa7242034223cdba6baf658a06c74096c9ab9
parent189036c0e71c51cea4939da60d1c7b75a6bf896b (diff)
downloadeobj-a8895a126992e5c5411513b5ef1a53dd2561b276.tar.gz
eobj-a8895a126992e5c5411513b5ef1a53dd2561b276.tar.bz2
eobj-a8895a126992e5c5411513b5ef1a53dd2561b276.zip
Eo: Added simple benchmark infra (not really testing anything atm).
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/PROTO/eobj@75712 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33
-rw-r--r--CMakeLists.txt1
-rw-r--r--src/benchmarks/CMakeLists.txt26
-rw-r--r--src/benchmarks/class_simple.c48
-rw-r--r--src/benchmarks/class_simple.h25
-rw-r--r--src/benchmarks/eo_bench.c53
-rw-r--r--src/benchmarks/eo_bench.h9
-rw-r--r--src/benchmarks/eo_bench_eo_do.c27
7 files changed, 189 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a466c64..8742a79 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -41,6 +41,7 @@ include(EFLCheck)
add_subdirectory(src/lib)
add_subdirectory(src/tests EXCLUDE_FROM_ALL)
+add_subdirectory(src/benchmarks EXCLUDE_FROM_ALL)
add_subdirectory(src/examples)
add_subdirectory(doc)
diff --git a/src/benchmarks/CMakeLists.txt b/src/benchmarks/CMakeLists.txt
new file mode 100644
index 0000000..84529d9
--- /dev/null
+++ b/src/benchmarks/CMakeLists.txt
@@ -0,0 +1,26 @@
+LIST(APPEND EO_SUITE_CC_SOURCES
+ eo_bench.c
+ eo_bench_eo_do.c
+ class_simple.c
+ )
+
+add_executable(eo_bench ${EO_SUITE_CC_SOURCES})
+
+include_directories(
+ ${EINA_INCLUDE_DIRS}
+ ${CMAKE_SOURCE_DIR}/src/lib
+ )
+
+get_target_property(eo_LIB_FILE eo LOCATION)
+target_link_libraries(eo_bench
+ ${EINA_LIBRARIES}
+ ${EINA_LDFLAGS_OTHER}
+ ${eo_LIB_FILE}
+ )
+
+add_dependencies(eo_bench eo)
+
+get_target_property(eo_bench_EXEC_FILE eo_bench LOCATION)
+add_custom_target(benchmark COMMAND ${eo_bench_EXEC_FILE} eo_bench)
+
+add_dependencies(benchmark eo_bench)
diff --git a/src/benchmarks/class_simple.c b/src/benchmarks/class_simple.c
new file mode 100644
index 0000000..6492d91
--- /dev/null
+++ b/src/benchmarks/class_simple.c
@@ -0,0 +1,48 @@
+#include "Eo.h"
+#include "class_simple.h"
+
+#include "config.h"
+
+#define MY_CLASS SIMPLE_CLASS
+
+EAPI Eo_Op SIMPLE_BASE_ID = 0;
+
+static void
+_a_set(Eo *obj EINA_UNUSED, void *class_data, va_list *list)
+{
+ Simple_Public_Data *pd = class_data;
+ int a;
+ a = va_arg(*list, int);
+
+ pd->a = a;
+}
+
+static void
+_class_constructor(Eo_Class *klass)
+{
+ const Eo_Op_Func_Description func_desc[] = {
+ EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
+ EO_OP_FUNC_SENTINEL
+ };
+
+ eo_class_funcs_set(klass, func_desc);
+}
+
+static const Eo_Op_Description op_desc[] = {
+ EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "Set property A"),
+ EO_OP_DESCRIPTION_SENTINEL
+};
+
+static const Eo_Class_Description class_desc = {
+ EO_VERSION,
+ "Simple",
+ EO_CLASS_TYPE_REGULAR,
+ EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
+ NULL,
+ sizeof(Simple_Public_Data),
+ _class_constructor,
+ NULL
+};
+
+EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL)
+
diff --git a/src/benchmarks/class_simple.h b/src/benchmarks/class_simple.h
new file mode 100644
index 0000000..86f07a1
--- /dev/null
+++ b/src/benchmarks/class_simple.h
@@ -0,0 +1,25 @@
+#ifndef SIMPLE_H
+#define SIMPLE_H
+
+#include "Eo.h"
+
+extern EAPI Eo_Op SIMPLE_BASE_ID;
+
+enum {
+ SIMPLE_SUB_ID_A_SET,
+ SIMPLE_SUB_ID_LAST
+};
+
+typedef struct
+{
+ int a;
+} Simple_Public_Data;
+
+#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id)
+
+#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_TYPECHECK(int, a)
+
+#define SIMPLE_CLASS simple_class_get()
+const Eo_Class *simple_class_get(void);
+
+#endif
diff --git a/src/benchmarks/eo_bench.c b/src/benchmarks/eo_bench.c
new file mode 100644
index 0000000..580f744
--- /dev/null
+++ b/src/benchmarks/eo_bench.c
@@ -0,0 +1,53 @@
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <limits.h>
+
+#include "Eo.h"
+#include "eo_bench.h"
+
+typedef struct _Eina_Benchmark_Case Eina_Benchmark_Case;
+struct _Eina_Benchmark_Case
+{
+ const char *bench_case;
+ void (*build)(Eina_Benchmark *bench);
+};
+
+static const Eina_Benchmark_Case etc[] = {
+ { "Eo_Do", eo_bench_eo_do },
+ { NULL, NULL }
+};
+
+int
+main(int argc, char **argv)
+{
+ Eina_Benchmark *test;
+ unsigned int i;
+
+ if (argc != 2)
+ return -1;
+
+ eina_init();
+ eo_init();
+
+ for (i = 0; etc[i].bench_case; ++i)
+ {
+ test = eina_benchmark_new(etc[i].bench_case, argv[1]);
+ if (!test)
+ continue;
+
+ etc[i].build(test);
+
+ eina_benchmark_run(test);
+
+ eina_benchmark_free(test);
+ }
+
+ eo_shutdown();
+ eina_shutdown();
+
+ return 0;
+}
diff --git a/src/benchmarks/eo_bench.h b/src/benchmarks/eo_bench.h
new file mode 100644
index 0000000..f55f1c3
--- /dev/null
+++ b/src/benchmarks/eo_bench.h
@@ -0,0 +1,9 @@
+#ifndef EINA_BENCH_H_
+#define EINA_BENCH_H_
+
+#include <Eina.h>
+#include <eina_benchmark.h>
+
+void eo_bench_eo_do(Eina_Benchmark *bench);
+
+#endif
diff --git a/src/benchmarks/eo_bench_eo_do.c b/src/benchmarks/eo_bench_eo_do.c
new file mode 100644
index 0000000..2b1991f
--- /dev/null
+++ b/src/benchmarks/eo_bench_eo_do.c
@@ -0,0 +1,27 @@
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "Eo.h"
+#include "eo_bench.h"
+
+#include "class_simple.h"
+
+static void
+bench_eo_do_general(int request)
+{
+ int i;
+ Eo *obj = eo_add(SIMPLE_CLASS, NULL);
+ for (i = 0 ; i < request ; i++)
+ {
+ eo_do(obj, simple_a_set(i));
+ }
+
+ eo_unref(obj);
+}
+
+void eo_bench_eo_do(Eina_Benchmark *bench)
+{
+ eina_benchmark_register(bench, "general",
+ EINA_BENCHMARK(bench_eo_do_general), 100, 10000, 500);
+}