jackdanielz pushed a commit to branch master.

commit b503a681ae87916954bf58b92e6114d3f30c9298
Author: Daniel Zaoui <[email protected]>
Date:   Thu Apr 18 13:55:11 2013 +0300

    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.
---
 src/benchmarks/eo/Makefile.am       |  3 ++-
 src/benchmarks/eo/eo_bench.c        |  1 +
 src/benchmarks/eo/eo_bench.h        |  1 +
 src/benchmarks/eo/eo_bench_eo_add.c | 47 +++++++++++++++++++++++++++++++++++++
 4 files changed, 51 insertions(+), 1 deletion(-)

diff --git a/src/benchmarks/eo/Makefile.am b/src/benchmarks/eo/Makefile.am
index 69b3dc1..d796710 100644
--- a/src/benchmarks/eo/Makefile.am
+++ b/src/benchmarks/eo/Makefile.am
@@ -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 \
diff --git a/src/benchmarks/eo/eo_bench.c b/src/benchmarks/eo/eo_bench.c
index 0da83a1..9266e6e 100644
--- a/src/benchmarks/eo/eo_bench.c
+++ b/src/benchmarks/eo/eo_bench.c
@@ -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 }
 };
 
diff --git a/src/benchmarks/eo/eo_bench.h b/src/benchmarks/eo/eo_bench.h
index feea3bc..2513426 100644
--- a/src/benchmarks/eo/eo_bench.h
+++ b/src/benchmarks/eo/eo_bench.h
@@ -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
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 0000000..ce0bdc9
--- /dev/null
+++ b/src/benchmarks/eo/eo_bench_eo_add.c
@@ -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);
+}

-- 

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr

Reply via email to