Eo: add benchmarks to measure eo_add.

The first one checks simple objects creation.
The second one creates objects, removes half of them and creates the same number.
This commit is contained in:
Daniel Zaoui 2013-04-18 13:55:11 +03:00
parent 715c77adb9
commit b503a681ae
4 changed files with 51 additions and 1 deletions

View File

@ -17,7 +17,8 @@ class_simple.c \
class_simple.h \
eo_bench.c \
eo_bench.h \
eo_bench_eo_do.c
eo_bench_eo_do.c \
eo_bench_eo_add.c
eo_bench_LDADD = \
$(top_builddir)/src/lib/eo/libeo.la \

View File

@ -20,6 +20,7 @@ struct _Eina_Benchmark_Case
static const Eina_Benchmark_Case etc[] = {
{ "eo_do", eo_bench_eo_do },
{ "eo_add", eo_bench_eo_add },
{ NULL, NULL }
};

View File

@ -2,5 +2,6 @@
#define EINA_BENCH_H_
void eo_bench_eo_do(Eina_Benchmark *bench);
void eo_bench_eo_add(Eina_Benchmark *bench);
#endif

View File

@ -0,0 +1,47 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "Eo.h"
#include "eo_bench.h"
#include "class_simple.h"
static void
bench_eo_add_linear(int request)
{
int i;
Eo **objs = calloc(request, sizeof(Eo *));
for (i = 0 ; i < request ; i++)
objs[i] = eo_add(SIMPLE_CLASS, NULL);
for (i = 0 ; i < request ; i++)
eo_unref(objs[i]);
free(objs);
}
static void
bench_eo_add_jump_by_2(int request)
{
int i;
Eo **objs = calloc(request, sizeof(Eo *));
for (i = 0 ; i < request ; i++)
objs[i] = eo_add(SIMPLE_CLASS, NULL);
for (i = 0 ; i < request ; i += 2)
eo_unref(objs[i]);
for (i = 0 ; i < request ; i += 2)
objs[i] = eo_add(SIMPLE_CLASS, NULL);
for (i = 0 ; i < request ; i++)
eo_unref(objs[i]);
free(objs);
}
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_register(bench, "eo_add_jump_by_2",
EINA_BENCHMARK(bench_eo_add_jump_by_2), 1000, 50000, 100);
}