[tracker/miner-fs-multi-insert: 13/17] tests/functional-tests: Added performance test for multi-insert
- From: Aleksander Morgado <aleksm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/miner-fs-multi-insert: 13/17] tests/functional-tests: Added performance test for multi-insert
- Date: Wed, 13 Oct 2010 17:17:21 +0000 (UTC)
commit 67e1f32b080f31b22b51aa4721652d33f86bd1a5
Author: Philip Van Hoof <philip codeminded be>
Date: Fri Oct 8 13:04:12 2010 +0200
tests/functional-tests: Added performance test for multi-insert
tests/functional-tests/.gitignore | 1 +
tests/functional-tests/Makefile.am | 14 ++-
.../update-array-performance-test.c | 221 ++++++++++++++++++++
3 files changed, 235 insertions(+), 1 deletions(-)
---
diff --git a/tests/functional-tests/.gitignore b/tests/functional-tests/.gitignore
index 4e59827..ac143f3 100644
--- a/tests/functional-tests/.gitignore
+++ b/tests/functional-tests/.gitignore
@@ -1,3 +1,4 @@
+update-array-performance-test
class-signal-performance-test
class-signal-performance-test.c
class-signal-test
diff --git a/tests/functional-tests/Makefile.am b/tests/functional-tests/Makefile.am
index 666da7d..c575d1a 100644
--- a/tests/functional-tests/Makefile.am
+++ b/tests/functional-tests/Makefile.am
@@ -87,7 +87,8 @@ noinst_PROGRAMS = busy-handling-test \
default-update-test \
bus-update-test \
class-signal-test \
- class-signal-performance-test
+ class-signal-performance-test \
+ update-array-performance-test
busy_handling_test_VALASOURCES = busy-handling-test.vala
@@ -118,6 +119,8 @@ default_update_test_SOURCES = \
bus_query_test_VALASOURCES = shared-query-test.vala bus-query-test.vala
+update_array_performance_test_SOURCES = update-array-performance-test.c
+
bus_query_test_SOURCES = \
bus-query-test.vala.stamp \
$(bus_query_test_VALASOURCES:.vala=.c)
@@ -208,6 +211,15 @@ class_signal_performance_test_LDADD = \
$(GLIB2_LIBS) \
$(DBUS_LIBS)
+update_array_performance_test_LDADD = \
+ $(top_builddir)/src/libtracker-direct/libtracker-direct.la \
+ $(top_builddir)/src/libtracker-bus/libtracker-bus.la \
+ $(top_builddir)/src/libtracker-sparql/libtracker-sparql-$(TRACKER_API_VERSION).la \
+ $(top_builddir)/src/libtracker-common/libtracker-common.la \
+ $(GIO_LIBS) \
+ $(GLIB2_LIBS) \
+ $(DBUS_LIBS)
+
BUILT_SOURCES = \
busy-handling-test.vala.stamp \
class-signal-test.vala.stamp \
diff --git a/tests/functional-tests/update-array-performance-test.c b/tests/functional-tests/update-array-performance-test.c
new file mode 100644
index 0000000..e8f29f1
--- /dev/null
+++ b/tests/functional-tests/update-array-performance-test.c
@@ -0,0 +1,221 @@
+/*
+ * Copyright (C) 2010, Codeminded BVBA <abustany gnome org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Copied from ../tracker-steroids/tracker-test.c
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <tracker-bus.h>
+#include <tracker-sparql.h>
+
+typedef struct {
+ GMainLoop *main_loop;
+ const gchar *query;
+ guint len, cur;
+} AsyncData;
+
+static TrackerSparqlConnection *connection;
+#define MSIZE 90
+#define TEST_STR "Brrr0092323"
+
+static const gchar *queries[90] = {
+ "INSERT { _:a0 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:a9 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:a11 a nmo:Message; nie:title '" TEST_STR "' }",
+ "INSERT { _:b0 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:b9 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:b11 a nmo:Message; nie:title '" TEST_STR "' }",
+ "INSERT { _:c0 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:c9 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:c12 a nmo:Message; nie:title '" TEST_STR "' }",
+ "INSERT { _:d0 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:d9 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:d12 a nmo:Message; nie:title '" TEST_STR "' }",
+ "INSERT { _:e0 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:e9 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:e11 a nmo:Message; nie:title '" TEST_STR "' }",
+ "INSERT { _:f0 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:f9 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:f11 a nmo:Message; nie:title '" TEST_STR "' }",
+ "INSERT { _:b1 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:b8 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:b13 a nmo:Message; nie:title '" TEST_STR "' }",
+ "INSERT { _:c1 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:c8 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:c13 a nmo:Message; nie:title '" TEST_STR "' }",
+ "INSERT { _:d1 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:d8 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:d14 a nmo:Message; nie:title '" TEST_STR "' }",
+ "INSERT { _:e1 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:e8 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:e14 a nmo:Message; nie:title '" TEST_STR "' }",
+ "INSERT { _:f1 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:f8 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:f15 a nmo:Message; nie:title '" TEST_STR "' }",
+ "INSERT { _:b2 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:b7 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:b15 a nmo:Message; nie:title '" TEST_STR "' }",
+ "INSERT { _:c2 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:c7 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:c15 a nmo:Message; nie:title '" TEST_STR "' }",
+ "INSERT { _:d2 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:d7 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:d16 a nmo:Message; nie:title '" TEST_STR "' }",
+ "INSERT { _:e2 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:e7 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:e16 a nmo:Message; nie:title '" TEST_STR "' }",
+ "INSERT { _:f2 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:f7 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:f17 a nmo:Message; nie:title '" TEST_STR "' }",
+ "INSERT { _:b3 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:b6 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:b16 a nmo:Message; nie:title '" TEST_STR "'}",
+ "INSERT { _:c3 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:c6 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:c18 a nmo:Message; nie:title '" TEST_STR "' }",
+ "INSERT { _:d3 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:d6 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:d19 a nmo:Message; nie:title '" TEST_STR "' }",
+ "INSERT { _:e3 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:e6 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:e20 a nmo:Message; nie:title '" TEST_STR "' }",
+ "INSERT { _:f3 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:f6 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:f21 a nmo:Message; nie:title '" TEST_STR "' }",
+ "INSERT { _:b4 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:b5 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:b22 a nmo:Message; nie:title '" TEST_STR "' }",
+ "INSERT { _:c4 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:c5 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:c23 a nmo:Message; nie:title '" TEST_STR "' }",
+ "INSERT { _:d4 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:d5 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:d24 a nmo:Message; nie:title '" TEST_STR "' }",
+ "INSERT { _:e4 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:e5 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:e24 a nmo:Message; nie:title '" TEST_STR "' }",
+ "INSERT { _:f4 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:f5 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:f25 a nmo:Message; nie:title '" TEST_STR "' }",
+ "INSERT { _:c5 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:c2 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:c26 a nmo:Message; nie:title '" TEST_STR "' }",
+ "INSERT { _:d5 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:d2 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:d28 a nmo:Message; nie:title '" TEST_STR "' }",
+ "INSERT { _:e5 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:e2 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:e29 a nmo:Message; nie:title '" TEST_STR "' }",
+ "INSERT { _:f5 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:f2 a nmo:Message; nie:title '" TEST_STR "' }", "INSERT { _:f33 a nmo:Message; nie:title '" TEST_STR "' }"};
+
+static void
+async_update_array_callback (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ AsyncData *data = user_data;
+ GPtrArray *errors;
+
+ errors = tracker_sparql_connection_update_array_finish (connection, result);
+ g_ptr_array_unref (errors);
+ g_main_loop_quit (data->main_loop);
+}
+
+
+static void
+test_tracker_sparql_update_array_async ()
+{
+ GMainLoop *main_loop;
+ AsyncData *data;
+
+ main_loop = g_main_loop_new (NULL, FALSE);
+
+ data = g_slice_new (AsyncData);
+ data->main_loop = main_loop;
+
+ /* Cast here is because vala doesn't make const-char-** possible :( */
+ tracker_sparql_connection_update_array_async (connection,
+ (char**) queries, MSIZE,
+ 0, NULL,
+ async_update_array_callback,
+ data);
+
+ g_main_loop_run (main_loop);
+
+ g_slice_free (AsyncData, data);
+ g_main_loop_unref (main_loop);
+
+}
+
+static void
+async_update_callback (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ AsyncData *data = user_data;
+ GError *error = NULL;
+
+ data->cur++;
+
+ tracker_sparql_connection_update_finish (connection, result, &error);
+ if (error)
+ g_error_free (error);
+
+ if (data->cur == data->len)
+ g_main_loop_quit (data->main_loop);
+}
+
+static void
+test_tracker_sparql_update_async ()
+{
+ guint i;
+ GMainLoop *main_loop;
+ AsyncData *data;
+
+ main_loop = g_main_loop_new (NULL, FALSE);
+
+ data = g_slice_new (AsyncData);
+ data->len = MSIZE;
+ data->main_loop = main_loop;
+ data->cur = 0;
+
+ for (i = 0; i < data->len; i++) {
+ tracker_sparql_connection_update_async (connection,
+ queries[i],
+ 0, NULL,
+ async_update_callback,
+ data);
+ }
+
+ g_main_loop_run (main_loop);
+
+ g_slice_free (AsyncData, data);
+ g_main_loop_unref (main_loop);
+
+}
+
+
+gint
+main (gint argc, gchar **argv)
+{
+ GTimer *array_t, *update_t;
+
+ g_type_init ();
+
+ /* do not require prior installation */
+ g_setenv ("TRACKER_SPARQL_MODULE_PATH", "../../src/libtracker-bus/.libs", TRUE);
+
+ connection = tracker_sparql_connection_get (NULL, NULL);
+
+ g_print ("First run (first update then array)\n");
+
+ tracker_sparql_connection_update (connection,
+ "DELETE { ?r a rdfs:Resource } WHERE { ?r nie:title '" TEST_STR "' }",
+ 0, NULL, NULL);
+
+ update_t = g_timer_new ();
+ test_tracker_sparql_update_async ();
+ g_timer_stop (update_t);
+
+ tracker_sparql_connection_update (connection,
+ "DELETE { ?r a rdfs:Resource } WHERE { ?r nie:title '" TEST_STR "' }",
+ 0, NULL, NULL);
+
+ array_t = g_timer_new ();
+ test_tracker_sparql_update_array_async ();
+ g_timer_stop (array_t);
+
+ tracker_sparql_connection_update (connection,
+ "DELETE { ?r a rdfs:Resource } WHERE { ?r nie:title '" TEST_STR "' }",
+ 0, NULL, NULL);
+
+ g_print ("Array: %f, Update: %f\n", g_timer_elapsed (array_t, NULL), g_timer_elapsed (update_t, NULL));
+
+ g_print ("Reversing run (first array then update)\n");
+
+ g_timer_destroy (array_t);
+ g_timer_destroy (update_t);
+
+ array_t = g_timer_new ();
+ test_tracker_sparql_update_array_async ();
+ g_timer_stop (array_t);
+
+ tracker_sparql_connection_update (connection,
+ "DELETE { ?r a rdfs:Resource } WHERE { ?r nie:title '" TEST_STR "' }",
+ 0, NULL, NULL);
+
+ update_t = g_timer_new ();
+ test_tracker_sparql_update_async ();
+ g_timer_stop (update_t);
+
+ tracker_sparql_connection_update (connection,
+ "DELETE { ?r a rdfs:Resource } WHERE { ?r nie:title '" TEST_STR "' }",
+ 0, NULL, NULL);
+
+ g_print ("Array: %f, Update: %f\n", g_timer_elapsed (array_t, NULL), g_timer_elapsed (update_t, NULL));
+
+ g_timer_destroy (array_t);
+ g_timer_destroy (update_t);
+ g_object_unref (connection);
+
+ return 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]