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
=== modified file 'configure.ac'
--- configure.ac 2012-03-21 19:15:14 +0000
+++ configure.ac 2012-03-29 04:40:23 +0000
@@ -118,7 +118,8 @@
118118
119AS_IF([test "x$enable_tests" != "xno"],[119AS_IF([test "x$enable_tests" != "xno"],[
120PKG_CHECK_MODULES(DBUSMENUTESTS, json-glib-1.0 >= $JSON_GLIB_REQUIRED_VERSION120PKG_CHECK_MODULES(DBUSMENUTESTS, json-glib-1.0 >= $JSON_GLIB_REQUIRED_VERSION
121 gio-unix-2.0 >= $GIO_UNIX_REQUIRED_VERSION,121 gio-unix-2.0 >= $GIO_UNIX_REQUIRED_VERSION
122 valgrind,
122 [have_tests=yes]123 [have_tests=yes]
123)124)
124])125])
125126
=== modified file 'tests/Makefile.am'
--- tests/Makefile.am 2012-03-27 20:11:33 +0000
+++ tests/Makefile.am 2012-03-29 04:40:23 +0000
@@ -16,7 +16,8 @@
1616
17if WANT_DBUSMENUDUMPER17if WANT_DBUSMENUDUMPER
18TESTS += \18TESTS += \
19 test-json19 test-json \
20 test-json-instruction
20endif21endif
2122
22if WANT_LIBDBUSMENUGTK23if WANT_LIBDBUSMENUGTK
@@ -242,6 +243,22 @@
242 $(DBUSMENUTESTS_LIBS) \243 $(DBUSMENUTESTS_LIBS) \
243 $(DBUSMENUGLIB_LIBS)244 $(DBUSMENUGLIB_LIBS)
244245
246#########################
247# Test JSON Instructions
248#########################
249
250test-json-instruction: test-json-client test-json-server test-json-instruction-count Makefile.am
251 @echo "#!/bin/bash" > $@
252 @echo export UBUNTU_MENUPROXY="" >> $@
253 @echo export G_DEBUG=fatal_criticals >> $@
254 @echo $(XVFB_RUN) >> $@
255 @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 >> $@
256 @chmod +x $@
257
258EXTRA_DIST += \
259 test-json-instruction-count
260
261
245######################262######################
246# Test Glib Submenu263# Test Glib Submenu
247######################264######################
248265
=== modified file 'tests/test-json-client.c'
--- tests/test-json-client.c 2012-03-27 20:11:33 +0000
+++ tests/test-json-client.c 2012-03-29 04:40:23 +0000
@@ -44,6 +44,8 @@
44 g_file_replace_contents(ofile, output, g_utf8_strlen(output, -1), NULL, FALSE, 0, NULL, NULL, NULL);44 g_file_replace_contents(ofile, output, g_utf8_strlen(output, -1), NULL, FALSE, 0, NULL, NULL, NULL);
45 }45 }
4646
47 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);
48
47 g_main_loop_quit(mainloop);49 g_main_loop_quit(mainloop);
48 return TRUE;50 return TRUE;
49}51}
@@ -53,7 +55,7 @@
53{55{
54 g_type_init();56 g_type_init();
5557
56 g_timeout_add_seconds(2, timeout_func, argv);58 g_timeout_add_seconds(1, timeout_func, argv);
5759
58 mainloop = g_main_loop_new(NULL, FALSE);60 mainloop = g_main_loop_new(NULL, FALSE);
59 g_main_loop_run(mainloop);61 g_main_loop_run(mainloop);
6062
=== added file 'tests/test-json-instruction-count'
--- tests/test-json-instruction-count 1970-01-01 00:00:00 +0000
+++ tests/test-json-instruction-count 2012-03-29 04:40:23 +0000
@@ -0,0 +1,6 @@
1#!/bin/sh
2
3COMMAND=$@
4INSTRUCTIONS=`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]*//'`
5
6echo "Instructions needed to execute '$COMMAND': $INSTRUCTIONS"
07
=== modified file 'tests/test-json-server.c'
--- tests/test-json-server.c 2010-11-17 04:04:47 +0000
+++ tests/test-json-server.c 2012-03-29 04:40:23 +0000
@@ -22,6 +22,7 @@
22#include <glib.h>22#include <glib.h>
23#include <gio/gio.h>23#include <gio/gio.h>
2424
25#include "callgrind.h"
25#include <libdbusmenu-glib/server.h>26#include <libdbusmenu-glib/server.h>
26#include <libdbusmenu-glib/menuitem.h>27#include <libdbusmenu-glib/menuitem.h>
2728
@@ -29,11 +30,14 @@
2930
30static GMainLoop * mainloop = NULL;31static GMainLoop * mainloop = NULL;
3132
32static gboolean33static void
33timer_func (gpointer data)34root_activate (void)
34{35{
36 g_debug("Dumping callgrind data");
37 CALLGRIND_DUMP_STATS_AT("exported");
38 CALLGRIND_STOP_INSTRUMENTATION;
35 g_main_loop_quit(mainloop);39 g_main_loop_quit(mainloop);
36 return FALSE;40 return;
37}41}
3842
39static void43static void
@@ -50,10 +54,14 @@
50 return;54 return;
51 }55 }
5256
57 g_signal_connect(G_OBJECT(root), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(root_activate), NULL);
58
59 g_debug("Starting Callgrind");
60 CALLGRIND_START_INSTRUMENTATION;
61 CALLGRIND_ZERO_STATS;
62 CALLGRIND_TOGGLE_COLLECT;
53 dbusmenu_server_set_root(server, root);63 dbusmenu_server_set_root(server, root);
5464
55 g_timeout_add(10000, timer_func, NULL);
56
57 return;65 return;
58}66}
5967

Subscribers

People subscribed via source and target branches

to all changes: