Eo benchmarks: Improve benchmarks.

Add more cases, and tune the number of times we test.
This commit is contained in:
Tom Hacohen 2015-10-14 10:54:02 +01:00
parent 9f6ec045a7
commit 862372ed23
5 changed files with 58 additions and 6 deletions

View File

@ -7,6 +7,17 @@
#define MY_CLASS SIMPLE_CLASS
static void
_other_call(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED, Eo *other, int times)
{
if (times > 0)
{
eo_do(other, simple_other_call(obj, times-1));
}
}
EAPI EO_VOID_FUNC_BODYV(simple_other_call, EO_FUNC_CALL(other, times), Eo *other, int times);
static void
_a_set(Eo *obj EINA_UNUSED, void *class_data, int a)
{
@ -18,6 +29,7 @@ EAPI EO_VOID_FUNC_BODYV(simple_a_set, EO_FUNC_CALL(a), int a);
static Eo_Op_Description op_desc[] = {
EO_OP_FUNC(simple_a_set, _a_set),
EO_OP_FUNC(simple_other_call, _other_call),
};
static const Eo_Class_Description class_desc = {

View File

@ -7,6 +7,9 @@ typedef struct
} Simple_Public_Data;
EAPI void simple_a_set(int a);
/* Calls simple_other_call(other, obj) and then simple_other_call(obj, other)
* for 'times' times in order to grow the call stack on other objects. */
EAPI void simple_other_call(Eo *other, int times);
#define SIMPLE_CLASS simple_class_get()
const Eo_Class *simple_class_get(void);

View File

@ -4,4 +4,6 @@
void eo_bench_eo_do(Eina_Benchmark *bench);
void eo_bench_eo_add(Eina_Benchmark *bench);
#define _EO_BENCH_TIMES(Start, Repeat, Jump) (Start), ((Start) + ((Jump) * (Repeat))), (Jump)
#endif

View File

@ -41,7 +41,7 @@ bench_eo_add_jump_by_2(int request)
void eo_bench_eo_add(Eina_Benchmark *bench)
{
eina_benchmark_register(bench, "eo_add_linear",
EINA_BENCHMARK(bench_eo_add_linear), 1000, 50000, 100);
EINA_BENCHMARK(bench_eo_add_linear), _EO_BENCH_TIMES(1000, 10, 50000));
eina_benchmark_register(bench, "eo_add_jump_by_2",
EINA_BENCHMARK(bench_eo_add_jump_by_2), 1000, 50000, 100);
EINA_BENCHMARK(bench_eo_add_jump_by_2), _EO_BENCH_TIMES(1000, 10, 50000));
}

View File

@ -7,7 +7,7 @@
#include "class_simple.h"
static void
bench_eo_do_general(int request)
bench_eo_do_simple(int request)
{
int i;
Eo *obj = eo_add(SIMPLE_CLASS, NULL);
@ -19,6 +19,37 @@ bench_eo_do_general(int request)
eo_unref(obj);
}
static void
bench_eo_do_two_objs(int request)
{
int i;
Eo *obj = eo_add(SIMPLE_CLASS, NULL);
Eo *obj2 = eo_add(SIMPLE_CLASS, NULL);
for (i = 0 ; i < request ; i++)
{
eo_do(obj, simple_a_set(i));
eo_do(obj2, simple_a_set(i));
}
eo_unref(obj);
eo_unref(obj2);
}
static void
bench_eo_do_two_objs_growing_stack(int request)
{
int i;
Eo *obj = eo_add(SIMPLE_CLASS, NULL);
Eo *obj2 = eo_add(SIMPLE_CLASS, NULL);
for (i = 0 ; i < request ; i++)
{
eo_do(obj, simple_other_call(obj2, 20));
}
eo_unref(obj);
eo_unref(obj2);
}
static const Eo_Class *cur_klass;
static void
@ -58,8 +89,12 @@ bench_eo_do_super(int request)
void eo_bench_eo_do(Eina_Benchmark *bench)
{
eina_benchmark_register(bench, "various",
EINA_BENCHMARK(bench_eo_do_general), 1000, 100000, 500);
eina_benchmark_register(bench, "simple",
EINA_BENCHMARK(bench_eo_do_simple), _EO_BENCH_TIMES(1000, 10, 500000));
eina_benchmark_register(bench, "super",
EINA_BENCHMARK(bench_eo_do_super), 1000, 100000, 500);
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));
}