forked from enlightenment/efl
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:
parent
715c77adb9
commit
b503a681ae
|
@ -17,7 +17,8 @@ class_simple.c \
|
||||||
class_simple.h \
|
class_simple.h \
|
||||||
eo_bench.c \
|
eo_bench.c \
|
||||||
eo_bench.h \
|
eo_bench.h \
|
||||||
eo_bench_eo_do.c
|
eo_bench_eo_do.c \
|
||||||
|
eo_bench_eo_add.c
|
||||||
|
|
||||||
eo_bench_LDADD = \
|
eo_bench_LDADD = \
|
||||||
$(top_builddir)/src/lib/eo/libeo.la \
|
$(top_builddir)/src/lib/eo/libeo.la \
|
||||||
|
|
|
@ -20,6 +20,7 @@ struct _Eina_Benchmark_Case
|
||||||
|
|
||||||
static const Eina_Benchmark_Case etc[] = {
|
static const Eina_Benchmark_Case etc[] = {
|
||||||
{ "eo_do", eo_bench_eo_do },
|
{ "eo_do", eo_bench_eo_do },
|
||||||
|
{ "eo_add", eo_bench_eo_add },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2,5 +2,6 @@
|
||||||
#define EINA_BENCH_H_
|
#define EINA_BENCH_H_
|
||||||
|
|
||||||
void eo_bench_eo_do(Eina_Benchmark *bench);
|
void eo_bench_eo_do(Eina_Benchmark *bench);
|
||||||
|
void eo_bench_eo_add(Eina_Benchmark *bench);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
Loading…
Reference in New Issue