summaryrefslogtreecommitdiff
path: root/src/benchmarks
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@samsung.com>2013-04-18 13:55:11 +0300
committerDaniel Zaoui <daniel.zaoui@samsung.com>2013-04-23 08:52:43 +0300
commitb503a681ae87916954bf58b92e6114d3f30c9298 (patch)
tree5444a54fa1289d03b20c18d50629e79e06f2293e /src/benchmarks
parent715c77adb9463aceaf8699c8c4aec4cca96a494e (diff)
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.
Diffstat (limited to 'src/benchmarks')
-rw-r--r--src/benchmarks/eo/Makefile.am3
-rw-r--r--src/benchmarks/eo/eo_bench.c1
-rw-r--r--src/benchmarks/eo/eo_bench.h1
-rw-r--r--src/benchmarks/eo/eo_bench_eo_add.c47
4 files changed, 51 insertions, 1 deletions
diff --git a/src/benchmarks/eo/Makefile.am b/src/benchmarks/eo/Makefile.am
index 69b3dc1849..d796710a7c 100644
--- a/src/benchmarks/eo/Makefile.am
+++ b/src/benchmarks/eo/Makefile.am
@@ -17,7 +17,8 @@ class_simple.c \
17class_simple.h \ 17class_simple.h \
18eo_bench.c \ 18eo_bench.c \
19eo_bench.h \ 19eo_bench.h \
20eo_bench_eo_do.c 20eo_bench_eo_do.c \
21eo_bench_eo_add.c
21 22
22eo_bench_LDADD = \ 23eo_bench_LDADD = \
23$(top_builddir)/src/lib/eo/libeo.la \ 24$(top_builddir)/src/lib/eo/libeo.la \
diff --git a/src/benchmarks/eo/eo_bench.c b/src/benchmarks/eo/eo_bench.c
index 0da83a1f34..9266e6efe2 100644
--- a/src/benchmarks/eo/eo_bench.c
+++ b/src/benchmarks/eo/eo_bench.c
@@ -20,6 +20,7 @@ struct _Eina_Benchmark_Case
20 20
21static const Eina_Benchmark_Case etc[] = { 21static const Eina_Benchmark_Case etc[] = {
22 { "eo_do", eo_bench_eo_do }, 22 { "eo_do", eo_bench_eo_do },
23 { "eo_add", eo_bench_eo_add },
23 { NULL, NULL } 24 { NULL, NULL }
24}; 25};
25 26
diff --git a/src/benchmarks/eo/eo_bench.h b/src/benchmarks/eo/eo_bench.h
index feea3bc333..2513426314 100644
--- a/src/benchmarks/eo/eo_bench.h
+++ b/src/benchmarks/eo/eo_bench.h
@@ -2,5 +2,6 @@
2#define EINA_BENCH_H_ 2#define EINA_BENCH_H_
3 3
4void eo_bench_eo_do(Eina_Benchmark *bench); 4void eo_bench_eo_do(Eina_Benchmark *bench);
5void eo_bench_eo_add(Eina_Benchmark *bench);
5 6
6#endif 7#endif
diff --git a/src/benchmarks/eo/eo_bench_eo_add.c b/src/benchmarks/eo/eo_bench_eo_add.c
new file mode 100644
index 0000000000..ce0bdc9c8c
--- /dev/null
+++ b/src/benchmarks/eo/eo_bench_eo_add.c
@@ -0,0 +1,47 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "eo_bench.h"
7#include "class_simple.h"
8
9static void
10bench_eo_add_linear(int request)
11{
12 int i;
13 Eo **objs = calloc(request, sizeof(Eo *));
14 for (i = 0 ; i < request ; i++)
15 objs[i] = eo_add(SIMPLE_CLASS, NULL);
16
17 for (i = 0 ; i < request ; i++)
18 eo_unref(objs[i]);
19 free(objs);
20}
21
22static void
23bench_eo_add_jump_by_2(int request)
24{
25 int i;
26 Eo **objs = calloc(request, sizeof(Eo *));
27 for (i = 0 ; i < request ; i++)
28 objs[i] = eo_add(SIMPLE_CLASS, NULL);
29
30 for (i = 0 ; i < request ; i += 2)
31 eo_unref(objs[i]);
32
33 for (i = 0 ; i < request ; i += 2)
34 objs[i] = eo_add(SIMPLE_CLASS, NULL);
35
36 for (i = 0 ; i < request ; i++)
37 eo_unref(objs[i]);
38 free(objs);
39}
40
41void eo_bench_eo_add(Eina_Benchmark *bench)
42{
43 eina_benchmark_register(bench, "eo_add_linear",
44 EINA_BENCHMARK(bench_eo_add_linear), 1000, 50000, 100);
45 eina_benchmark_register(bench, "eo_add_jump_by_2",
46 EINA_BENCHMARK(bench_eo_add_jump_by_2), 1000, 50000, 100);
47}