Eo: Added simple benchmark infra (not really testing anything atm).

SVN revision: 75712
This commit is contained in:
Tom Hacohen 2012-08-26 13:18:44 +00:00
parent 4c7a23d21e
commit e8ad8e3a93
7 changed files with 189 additions and 0 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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;
}

View File

@ -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

View File

@ -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);
}