diff options
author | Georges Basile Stavracas Neto <georges.stavracas@gmail.com> | 2020-09-02 17:35:23 -0300 |
---|---|---|
committer | Georges Basile Stavracas Neto <georges.stavracas@gmail.com> | 2022-08-20 01:34:37 -0300 |
commit | 6992f5b74c8a82b785835ba57f1b7c576117cfb1 (patch) | |
tree | fd444392c2803942db93df6b990dacbc17b9cef2 | |
parent | 712fd3cec8441adb728e4cc0159d429a3f51c0ea (diff) | |
download | gnome-shell-gbsneto/profiling-for-real.tar.gz |
plugin: Implement profiling vfuncsgbsneto/profiling-for-real
Use the new GJS API to pass an external capture writer, and
start/stop whenever the compositor asks us to do so.
-rw-r--r-- | src/gnome-shell-plugin.c | 47 | ||||
-rw-r--r-- | src/shell-global.c | 3 |
2 files changed, 50 insertions, 0 deletions
diff --git a/src/gnome-shell-plugin.c b/src/gnome-shell-plugin.c index 5364f043a..537487bac 100644 --- a/src/gnome-shell-plugin.c +++ b/src/gnome-shell-plugin.c @@ -352,6 +352,48 @@ gnome_shell_plugin_locate_pointer (MetaPlugin *plugin) _shell_global_locate_pointer (shell_plugin->global); } +#ifdef COGL_HAS_TRACING +static void +gnome_shell_plugin_start_profiler (MetaPlugin *plugin, + SysprofCaptureWriter *writer) +{ + ShellGlobal *global; + GjsProfiler *profiler; + GjsContext *context; + + global = shell_global_get (); + g_return_if_fail (global); + + context = _shell_global_get_gjs_context (global); + g_return_if_fail (context); + + profiler = gjs_context_get_profiler (context); + g_return_if_fail (profiler); + + gjs_profiler_set_capture_writer (profiler, writer); + gjs_profiler_start (profiler); +} + +static void +gnome_shell_plugin_stop_profiler (MetaPlugin *plugin) +{ + ShellGlobal *global; + GjsProfiler *profiler; + GjsContext *context; + + global = shell_global_get (); + g_return_if_fail (global); + + context = _shell_global_get_gjs_context (global); + g_return_if_fail (context); + + profiler = gjs_context_get_profiler (context); + g_return_if_fail (profiler); + + gjs_profiler_stop (profiler); +} +#endif + static void gnome_shell_plugin_class_init (GnomeShellPluginClass *klass) { @@ -386,6 +428,11 @@ gnome_shell_plugin_class_init (GnomeShellPluginClass *klass) plugin_class->create_inhibit_shortcuts_dialog = gnome_shell_plugin_create_inhibit_shortcuts_dialog; plugin_class->locate_pointer = gnome_shell_plugin_locate_pointer; + +#ifdef COGL_HAS_TRACING + plugin_class->start_profiler = gnome_shell_plugin_start_profiler; + plugin_class->stop_profiler = gnome_shell_plugin_stop_profiler; +#endif } static void diff --git a/src/shell-global.c b/src/shell-global.c index 0ccdb1029..6905a52b9 100644 --- a/src/shell-global.c +++ b/src/shell-global.c @@ -439,6 +439,9 @@ shell_global_init (ShellGlobal *global) global->js_context = g_object_new (GJS_TYPE_CONTEXT, "search-path", search_path, +#ifdef COGL_HAS_TRACING + "profiler-enabled", TRUE, +#endif NULL); g_strfreev (search_path); |