Merge lp:~ted/libdbusmenu/instruction-count-testing into lp:libdbusmenu/0.6

Proposed by Ted Gould
Status: Merged
Approved by: Charles Kerr
Approved revision: 396
Merged at revision: 395
Proposed branch: lp:~ted/libdbusmenu/instruction-count-testing
Merge into: lp:libdbusmenu/0.6
Diff against target: 129 lines (+42/-8)
5 files modified
configure.ac (+2/-1)
tests/Makefile.am (+18/-1)
tests/test-json-client.c (+3/-1)
tests/test-json-instruction-count (+6/-0)
tests/test-json-server.c (+13/-5)
To merge this branch: bzr merge lp:~ted/libdbusmenu/instruction-count-testing
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
Review via email: mp+99867@code.launchpad.net

Description of the change

Cool, got this working with help from Chase. Basically it prints the number of instructions that are used from exporting a menu structure over the bus. For instance, Chris' patch took the number from ~350M to ~150M. Hopefully we can use this to track performance issues over time.

To post a comment you must log in.
Revision history for this message
Charles Kerr (charlesk) wrote :

Wow, that's a neat idea. I didn't even know there /was/ a callgrind.h.

Revision history for this message
Charles Kerr (charlesk) wrote :

Ted, how did you invoke the tests to measure the number of instructions?

Revision history for this message
Ted Gould (ted) wrote :

You can do it like this:

$ cd tests
$ make test-json-instruction
$ ./test-json-instruction

Revision history for this message
Charles Kerr (charlesk) wrote :

I really like this idea and look forward to stealing it.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'configure.ac'
2--- configure.ac 2012-03-21 19:15:14 +0000
3+++ configure.ac 2012-03-29 04:40:23 +0000
4@@ -118,7 +118,8 @@
5
6 AS_IF([test "x$enable_tests" != "xno"],[
7 PKG_CHECK_MODULES(DBUSMENUTESTS, json-glib-1.0 >= $JSON_GLIB_REQUIRED_VERSION
8- gio-unix-2.0 >= $GIO_UNIX_REQUIRED_VERSION,
9+ gio-unix-2.0 >= $GIO_UNIX_REQUIRED_VERSION
10+ valgrind,
11 [have_tests=yes]
12 )
13 ])
14
15=== modified file 'tests/Makefile.am'
16--- tests/Makefile.am 2012-03-27 20:11:33 +0000
17+++ tests/Makefile.am 2012-03-29 04:40:23 +0000
18@@ -16,7 +16,8 @@
19
20 if WANT_DBUSMENUDUMPER
21 TESTS += \
22- test-json
23+ test-json \
24+ test-json-instruction
25 endif
26
27 if WANT_LIBDBUSMENUGTK
28@@ -242,6 +243,22 @@
29 $(DBUSMENUTESTS_LIBS) \
30 $(DBUSMENUGLIB_LIBS)
31
32+#########################
33+# Test JSON Instructions
34+#########################
35+
36+test-json-instruction: test-json-client test-json-server test-json-instruction-count Makefile.am
37+ @echo "#!/bin/bash" > $@
38+ @echo export UBUNTU_MENUPROXY="" >> $@
39+ @echo export G_DEBUG=fatal_criticals >> $@
40+ @echo $(XVFB_RUN) >> $@
41+ @echo $(DBUS_RUNNER) --task $(builddir)/test-json-client --wait-for org.dbusmenu.test --task-name Client --parameter $(top_builddir)/tools/dbusmenu-dumper --parameter /dev/null --ignore-return --task libtool --parameter --mode=execute --parameter $(srcdir)/test-json-instruction-count --parameter $(builddir)/test-json-server --task-name Server --parameter $(srcdir)/test-json-01.json --ignore-return >> $@
42+ @chmod +x $@
43+
44+EXTRA_DIST += \
45+ test-json-instruction-count
46+
47+
48 ######################
49 # Test Glib Submenu
50 ######################
51
52=== modified file 'tests/test-json-client.c'
53--- tests/test-json-client.c 2012-03-27 20:11:33 +0000
54+++ tests/test-json-client.c 2012-03-29 04:40:23 +0000
55@@ -44,6 +44,8 @@
56 g_file_replace_contents(ofile, output, g_utf8_strlen(output, -1), NULL, FALSE, 0, NULL, NULL, NULL);
57 }
58
59+ g_spawn_command_line_sync("gdbus call --session --dest org.dbusmenu.test --object-path /org/test --method com.canonical.dbusmenu.Event 0 clicked \"<0>\" 0", NULL, NULL, NULL, NULL);
60+
61 g_main_loop_quit(mainloop);
62 return TRUE;
63 }
64@@ -53,7 +55,7 @@
65 {
66 g_type_init();
67
68- g_timeout_add_seconds(2, timeout_func, argv);
69+ g_timeout_add_seconds(1, timeout_func, argv);
70
71 mainloop = g_main_loop_new(NULL, FALSE);
72 g_main_loop_run(mainloop);
73
74=== added file 'tests/test-json-instruction-count'
75--- tests/test-json-instruction-count 1970-01-01 00:00:00 +0000
76+++ tests/test-json-instruction-count 2012-03-29 04:40:23 +0000
77@@ -0,0 +1,6 @@
78+#!/bin/sh
79+
80+COMMAND=$@
81+INSTRUCTIONS=`valgrind --tool=callgrind --callgrind-out-file=/dev/null --instr-atstart=no --collect-atstart=no --combine-dumps=yes $COMMAND 2>&1 > /dev/null | grep refs | grep I | tail --lines=1 | cut -d ":" -f 2 | sed -e 's/^[ \t]*//'`
82+
83+echo "Instructions needed to execute '$COMMAND': $INSTRUCTIONS"
84
85=== modified file 'tests/test-json-server.c'
86--- tests/test-json-server.c 2010-11-17 04:04:47 +0000
87+++ tests/test-json-server.c 2012-03-29 04:40:23 +0000
88@@ -22,6 +22,7 @@
89 #include <glib.h>
90 #include <gio/gio.h>
91
92+#include "callgrind.h"
93 #include <libdbusmenu-glib/server.h>
94 #include <libdbusmenu-glib/menuitem.h>
95
96@@ -29,11 +30,14 @@
97
98 static GMainLoop * mainloop = NULL;
99
100-static gboolean
101-timer_func (gpointer data)
102+static void
103+root_activate (void)
104 {
105+ g_debug("Dumping callgrind data");
106+ CALLGRIND_DUMP_STATS_AT("exported");
107+ CALLGRIND_STOP_INSTRUMENTATION;
108 g_main_loop_quit(mainloop);
109- return FALSE;
110+ return;
111 }
112
113 static void
114@@ -50,10 +54,14 @@
115 return;
116 }
117
118+ g_signal_connect(G_OBJECT(root), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(root_activate), NULL);
119+
120+ g_debug("Starting Callgrind");
121+ CALLGRIND_START_INSTRUMENTATION;
122+ CALLGRIND_ZERO_STATS;
123+ CALLGRIND_TOGGLE_COLLECT;
124 dbusmenu_server_set_root(server, root);
125
126- g_timeout_add(10000, timer_func, NULL);
127-
128 return;
129 }
130

Subscribers

People subscribed via source and target branches

to all changes: