summaryrefslogtreecommitdiff
path: root/src/benchmarks/eo/eo_bench_eo_add.c
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/eo/eo_bench_eo_add.c
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/eo/eo_bench_eo_add.c')
-rw-r--r--src/benchmarks/eo/eo_bench_eo_add.c47
1 files changed, 47 insertions, 0 deletions
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}