efl/src/benchmarks/eo/eo_bench_eo_do.c

106 lines
2.3 KiB
C
Raw Normal View History

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "Eo.h"
#include "eo_bench.h"
#include "class_simple.h"
static void
bench_eo_do_simple(int request)
{
int i;
Eo *obj = efl_add_ref(SIMPLE_CLASS, NULL);
for (i = 0 ; i < request ; i++)
{
simple_a_set(obj, i);
}
efl_unref(obj);
}
static void
bench_eo_do_two_objs(int request)
{
int i;
Eo *obj = efl_add_ref(SIMPLE_CLASS, NULL);
Eo *obj2 = efl_add_ref(SIMPLE_CLASS, NULL);
for (i = 0 ; i < request ; i++)
{
simple_a_set(obj, i);
simple_a_set(obj2, i);
}
efl_unref(obj);
efl_unref(obj2);
}
static void
bench_eo_do_two_objs_growing_stack(int request)
{
int i;
Eo *obj = efl_add_ref(SIMPLE_CLASS, NULL);
Eo *obj2 = efl_add_ref(SIMPLE_CLASS, NULL);
for (i = 0 ; i < request ; i++)
{
simple_other_call(obj, obj2, 20);
}
efl_unref(obj);
efl_unref(obj2);
}
static const Efl_Class *cur_klass;
2013-03-13 09:32:04 -07:00
static void
2014-04-23 01:23:39 -07:00
_a_set(Eo *obj, void *class_data EINA_UNUSED, int a)
2013-03-13 09:32:04 -07:00
{
simple_a_set(efl_super(obj, cur_klass), a);
2013-03-13 09:32:04 -07:00
}
static Eina_Bool
_class_initializer(Efl_Class *klass)
{
EFL_OPS_DEFINE(ops,
EFL_OBJECT_OP_FUNC(simple_a_set, _a_set),
);
return efl_class_functions_set(klass, &ops, NULL);
}
2015-10-14 02:28:41 -07:00
2013-03-13 09:32:04 -07:00
static void
bench_eo_do_super(int request)
{
static Efl_Class_Description class_desc = {
2013-03-13 09:32:04 -07:00
EO_VERSION,
"Simple2",
EFL_CLASS_TYPE_REGULAR,
2013-03-13 09:32:04 -07:00
0,
_class_initializer,
2014-04-23 01:23:39 -07:00
NULL,
2013-03-13 09:32:04 -07:00
NULL
};
cur_klass = efl_class_new(&class_desc, SIMPLE_CLASS, NULL);
2013-03-13 09:32:04 -07:00
int i;
Eo *obj = efl_add_ref(cur_klass, NULL);
2013-03-13 09:32:04 -07:00
for (i = 0 ; i < request ; i++)
{
simple_a_set(obj, i);
2013-03-13 09:32:04 -07:00
}
efl_unref(obj);
2013-03-13 09:32:04 -07:00
}
void eo_bench_eo_do(Eina_Benchmark *bench)
{
eina_benchmark_register(bench, "simple",
EINA_BENCHMARK(bench_eo_do_simple), _EO_BENCH_TIMES(1000, 10, 500000));
2013-03-13 09:32:04 -07:00
eina_benchmark_register(bench, "super",
EINA_BENCHMARK(bench_eo_do_super), _EO_BENCH_TIMES(1000, 10, 500000));
eina_benchmark_register(bench, "two_objs",
EINA_BENCHMARK(bench_eo_do_two_objs), _EO_BENCH_TIMES(1000, 10, 500000));
eina_benchmark_register(bench, "two_objs_growing_stack",
EINA_BENCHMARK(bench_eo_do_two_objs_growing_stack), _EO_BENCH_TIMES(1000, 10, 40000));
}