[tracker/signal-timer] functional-tests: ipc: Add test for signal-enhancement for batch_update
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/signal-timer] functional-tests: ipc: Add test for signal-enhancement for batch_update
- Date: Fri, 17 Dec 2010 13:28:49 +0000 (UTC)
commit e2a75700062e20999e55114cda95e6757b07283e
Author: Philip Van Hoof <philip codeminded be>
Date: Fri Dec 17 14:28:20 2010 +0100
functional-tests: ipc: Add test for signal-enhancement for batch_update
tests/functional-tests/ipc/.gitignore | 2 +
tests/functional-tests/ipc/Makefile.am | 15 ++
.../ipc/test-class-signal-performance-batch.vala | 151 ++++++++++++++++++++
3 files changed, 168 insertions(+), 0 deletions(-)
---
diff --git a/tests/functional-tests/ipc/.gitignore b/tests/functional-tests/ipc/.gitignore
index 35c2d22..27f9a25 100644
--- a/tests/functional-tests/ipc/.gitignore
+++ b/tests/functional-tests/ipc/.gitignore
@@ -1,4 +1,6 @@
test-update-array-performance
+test-class-signal-performance-batch
+test-class-signal-performance-batch.c
test-class-signal-performance
test-class-signal-performance.c
test-class-signal
diff --git a/tests/functional-tests/ipc/Makefile.am b/tests/functional-tests/ipc/Makefile.am
index 6459837..8987fed 100644
--- a/tests/functional-tests/ipc/Makefile.am
+++ b/tests/functional-tests/ipc/Makefile.am
@@ -7,6 +7,7 @@ include $(top_srcdir)/Makefile.decl
# test-busy-handling
# test-class-signal
# test-class-signal-performance
+# test-class-signal-performance-batch
#
noinst_PROGRAMS = \
test-busy-handling \
@@ -16,6 +17,7 @@ noinst_PROGRAMS = \
test-bus-update \
test-class-signal \
test-class-signal-performance \
+ test-class-signal-performance-batch \
test-update-array-performance
AM_VALAFLAGS = \
@@ -93,3 +95,16 @@ test_class_signal_performance_VALAFLAGS = \
test_class_signal_performance_LDADD = \
$(LDADD) \
$(TRACKER_DBUS_LIBS)
+
+test_class_signal_performance_batch_SOURCES = \
+ test-class-signal-performance-batch.vala
+test_class_signal_performance_batch_CFLAGS = \
+ $(AM_CPPFLAGS) \
+ $(TRACKER_DBUS_CFLAGS)
+test_class_signal_performance_batch_VALAFLAGS = \
+ --pkg dbus-glib-1 \
+ $(AM_VALAFLAGS)
+test_class_signal_performance_batch_LDADD = \
+ $(LDADD) \
+ $(TRACKER_DBUS_LIBS)
+
diff --git a/tests/functional-tests/ipc/test-class-signal-performance-batch.vala b/tests/functional-tests/ipc/test-class-signal-performance-batch.vala
new file mode 100644
index 0000000..822a3bf
--- /dev/null
+++ b/tests/functional-tests/ipc/test-class-signal-performance-batch.vala
@@ -0,0 +1,151 @@
+/*
+ * Copyright (C) 2008, Nokia <ivan frade nokia com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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 Library 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.
+ */
+
+using Tracker;
+using Tracker.Sparql;
+
+const int max_signals = 1000;
+// const int max_signals = 10000;
+const string title_data = "title";
+
+struct Event {
+ int graph_id;
+ int subject_id;
+ int pred_id;
+ int object_id;
+}
+
+[DBus (name = "org.freedesktop.Tracker1.Resources")]
+private interface Resources : GLib.Object {
+ [DBus (name = "GraphUpdated")]
+ public signal void graph_updated (string class_name, Event[] deletes, Event[] inserts);
+
+ [DBus (name = "BatchSparqlUpdate")]
+ public abstract async void batch_sparql_update_async (string query) throws Sparql.Error, DBus.Error;
+
+ [DBus (name = "SparqlUpdate")]
+ public abstract async void sparql_update_async (string query) throws Sparql.Error, DBus.Error;
+
+}
+
+[DBus (name = "org.freedesktop.Tracker1.Resources.Class")]
+private interface ResourcesClass : GLib.Object {
+ [DBus (name = "SubjectsAdded")]
+ public signal void subjects_added (string [] subjects);
+ [DBus (name = "SubjectsChanged")]
+ public signal void subjects_changed (string [] subjects, string [] preds);
+}
+
+public class TestApp {
+ static DBus.Connection dbus_connection;
+ static Resources resources_object;
+ static ResourcesClass class_object;
+ MainLoop loop;
+ bool initialized = false;
+ Sparql.Connection con;
+ int count = 0;
+ GLib.Timer t;
+
+ public TestApp ()
+ requires (!initialized) {
+ try {
+ con = Tracker.Sparql.Connection.get();
+ dbus_connection = DBus.Bus.get (DBus.BusType.SESSION);
+ resources_object = (Resources) dbus_connection.get_object ("org.freedesktop.Tracker1",
+ "/org/freedesktop/Tracker1/Resources",
+ "org.freedesktop.Tracker1.Resources");
+
+ class_object = (ResourcesClass) dbus_connection.get_object ("org.freedesktop.Tracker1",
+ "/org/freedesktop/Tracker1/Resources/Classes/nmm/MusicPiece",
+ "org.freedesktop.Tracker1.Resources.Class");
+
+ class_object.subjects_added.connect (on_subjects_added);
+ class_object.subjects_changed.connect (on_subjects_changed);
+
+ resources_object.graph_updated.connect (on_graph_updated_received);
+ t = new GLib.Timer ();
+
+ } catch (GLib.Error e) {
+ warning ("Could not connect to D-Bus service: %s", e.message);
+ initialized = false;
+ return;
+ }
+ initialized = true;
+ }
+
+ private void on_subjects_changed (string [] subjects, string [] preds) {
+ foreach (string s in subjects)
+ count++;
+
+ //if (count == 20002)
+ print ("Old class signal count=%d time=%lf\n", count, t.elapsed ());
+ }
+
+ private void on_subjects_added (string [] subjects) {
+ foreach (string s in subjects)
+ count++;
+
+ //if (count == 20002)
+ print ("Old class signal count=%d time=%lf\n", count, t.elapsed ());
+ }
+
+ private void on_graph_updated_received (string class_name, Event[] deletes, Event[] inserts) {
+ foreach (Event insert in inserts)
+ count++;
+ //if (count == 20002)
+ print ("New class signal count=%d time=%lf\n", count, t.elapsed ());
+ }
+
+ private void insert_data () {
+ int i;
+// for (i = 0; i <= max_signals; i++) {
+// string upqry = "DELETE { <%d> a rdfs:Resource }".printf(i);
+// resources_object.sparql_update_async (upqry);
+// }
+
+ t.start();
+ for (i = 0; i <= max_signals; i++) {
+ string upqry = "INSERT { <%d> a nmm:MusicPiece ; nie:title '%s %d' }".printf(i, title_data, i);
+
+ if (i == max_signals / 2) {
+ resources_object.sparql_update_async (upqry);
+ } else {
+ resources_object.batch_sparql_update_async (upqry);
+ }
+ }
+ }
+
+ private bool in_mainloop () {
+ insert_data ();
+ return false;
+ }
+
+ public int run () {
+ loop = new MainLoop (null, false);
+ Idle.add (in_mainloop);
+ loop.run ();
+ return 0;
+ }
+}
+
+int main (string[] args) {
+ TestApp app = new TestApp ();
+
+ return app.run ();
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]