[tracker/dbus-fd-experiment] Add simple bench program for Steroids update



commit ce99e7efbf995b895f6cb214788a404538f5a411
Author: Adrien Bustany <abustany gnome org>
Date:   Wed Jun 2 09:53:21 2010 -0400

    Add simple bench program for Steroids update

 examples/steroids/Makefile.am        |    6 ++-
 examples/steroids/benchmark-update.c |   73 ++++++++++++++++++++++++++++++++++
 2 files changed, 78 insertions(+), 1 deletions(-)
---
diff --git a/examples/steroids/Makefile.am b/examples/steroids/Makefile.am
index a390607..09dda67 100644
--- a/examples/steroids/Makefile.am
+++ b/examples/steroids/Makefile.am
@@ -13,13 +13,15 @@ INCLUDES =							\
 	$(GIO_CFLAGS)						\
 	$(DBUS_CFLAGS)
 
-noinst_PROGRAMS = steroids-sparql benchmark
+noinst_PROGRAMS = steroids-sparql benchmark benchmark-update
 
 steroids_sparql_SOURCES =					\
 	steroids-sparql.c
 
 benchmark_SOURCES= benchmark.c
 
+benchmark_update_SOURCES=benchmark-update.c
+
 steroids_sparql_LDADD =						\
        $(top_builddir)/src/libtracker-client/libtracker-client- TRACKER_API_VERSION@.la \
        $(top_builddir)/src/libtracker-common/libtracker-common.la \
@@ -33,3 +35,5 @@ steroids_sparql_LDADD =						\
        -lm
 
 benchmark_LDADD= $(steroids_sparql_LDADD)
+
+benchmark_update_LDADD= $(steroids_sparql_LDADD)
diff --git a/examples/steroids/benchmark-update.c b/examples/steroids/benchmark-update.c
new file mode 100644
index 0000000..4fb76bb
--- /dev/null
+++ b/examples/steroids/benchmark-update.c
@@ -0,0 +1,73 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <libtracker-client/tracker.h>
+
+#define N_TRIES 500
+
+int
+main (int argc, char **argv)
+{
+	const char *query;
+	TrackerClient *client;
+	GError *error = NULL;
+	GTimer *timer;
+	int i;
+	double time_normal, time_steroids;
+
+	if (argc != 2) {
+		fprintf (stderr, "Usage: %s query\n", argv[0]);
+		exit (1);
+	}
+
+	query = argv[1];
+
+	client = tracker_client_new (0, 0);
+
+	/* Run a first time to warm cache */
+	for (i = 0; i < N_TRIES; i++) {
+		tracker_resources_sparql_update (client, query, &error);
+
+		if (error) {
+			g_critical ("Query error: %s", error->message);
+			g_error_free (error);
+			exit (1);
+		}
+	}
+
+	timer = g_timer_new ();
+
+	for (i = 0; i < N_TRIES; i++) {
+		tracker_resources_sparql_update (client, query, &error);
+
+		if (error) {
+			g_critical ("Query error: %s", error->message);
+			g_error_free (error);
+			g_timer_destroy (timer);
+			exit (1);
+		}
+	}
+
+	time_normal = g_timer_elapsed (timer, NULL);
+
+	g_timer_start (timer);
+
+	for (i = 0; i < N_TRIES; i++) {
+		tracker_resources_sparql_update_fast (client, query, &error);
+
+		if (error) {
+			g_critical ("Query error: %s", error->message);
+			g_error_free (error);
+			g_timer_destroy (timer);
+			exit (1);
+		}
+	}
+
+	time_steroids = g_timer_elapsed (timer, NULL);
+
+	printf ("Normal:   %f seconds\n", time_normal/N_TRIES);
+	printf ("Steroids: %f seconds\n", time_steroids/N_TRIES);
+	printf ("Speedup:  %f %%\n", 100 * (time_normal/time_steroids - 1));
+
+	return 0;
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]