[mutter/gbsneto/tracing: 66/68] Add mutter-profiler script
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gbsneto/tracing: 66/68] Add mutter-profiler script
- Date: Wed, 12 Sep 2018 11:55:59 +0000 (UTC)
commit 7cf2ff39548c72e7ee1dca382aba5d48cfb1c6da
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Fri Aug 10 20:46:28 2018 -0300
Add mutter-profiler script
The script merely calls the Sysprof API with the right
arguments to run it without Sysprof.
Usage is trivial:
$ mutter-profiler <SECONDS>
Where <SECONDS> is the number of seconds that Cogl calls
will be captured. It'll save the resulting syscap file at
the home directory named as 'cogl-trace-sp-capture.syscap.'
No frames were harmed when writing this tool.
tools/mutter-profiler | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 88 insertions(+)
---
diff --git a/tools/mutter-profiler b/tools/mutter-profiler
new file mode 100755
index 000000000..397e4e97c
--- /dev/null
+++ b/tools/mutter-profiler
@@ -0,0 +1,88 @@
+#!/usr/bin/python3
+#
+# Copyright (C) 2018 Georges Basile Stavracas Neto <gbsneto gnome org>
+#
+# This program 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 program 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 program; if not, see <http://www.gnu.org/licenses/>.
+
+
+from gi.repository import GLib, Gio
+
+import argparse
+import logging
+import sys
+
+log = logging.getLogger('mutter-profiler')
+
+def setup_logging(enable_debug):
+ """Setup the logging level"""
+ log_level = logging.INFO
+
+ if enable_debug:
+ log_level = logging.DEBUG
+ logging.info('Debug enabled')
+
+ log.setLevel(log_level)
+
+
+def start_profiler(seconds):
+ """
+ Calls the D-Bus method for profiling with the passed number
+ of seconds. The result is printed for debugging purposes but
+ not used.
+
+ @seconds: number of seconds to capture profiling data
+ """
+ proxy = Gio.DBusProxy.new_for_bus_sync(
+ Gio.BusType.SESSION,
+ Gio.DBusProxyFlags.DO_NOT_AUTO_START,
+ None,
+ 'org.gnome.Mutter.IdleMonitor',
+ '/org/gnome/Sysprof/Profiler',
+ 'org.gnome.Sysprof.Capturer',
+ None)
+
+ params = GLib.Variant('(a{sv})', ({
+ 'timeout': GLib.Variant('u', seconds),
+ }, ))
+ log.debug('Sending parameters: {}'.format(params))
+
+
+ result = proxy.call_sync('Capture', params, 0, 10000, None)
+ log.debug('Result: {}'.format(result))
+
+ if result[0] != -1:
+ log.critical('Wrong result received')
+ else:
+ log.info('Success')
+
+
+def main():
+ """Sets various options and runs the auxiliary helper."""
+ parser = argparse.ArgumentParser(
+ description='Capture Mutter profiling data with Sysprof')
+ parser.add_argument('seconds', type=int,
+ help='Timeout (in seconds) to capture data')
+ parser.add_argument('-d', '--debug', action='store_true',
+ help='Show debug messages')
+
+ args = parser.parse_args()
+
+ setup_logging(args.debug)
+ start_profiler(args.seconds)
+
+ return 0
+
+if __name__ == '__main__':
+ sys.exit(main())
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]