[gnome-shell/gbsneto/profiling-for-real] plugin: Implement profiling vfuncs
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gbsneto/profiling-for-real] plugin: Implement profiling vfuncs
- Date: Sat, 20 Aug 2022 04:34:35 +0000 (UTC)
commit 6992f5b74c8a82b785835ba57f1b7c576117cfb1
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Wed Sep 2 17:35:23 2020 -0300
plugin: Implement profiling vfuncs
Use the new GJS API to pass an external capture writer, and
start/stop whenever the compositor asks us to do so.
src/gnome-shell-plugin.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
src/shell-global.c | 3 +++
2 files changed, 50 insertions(+)
---
diff --git a/src/gnome-shell-plugin.c b/src/gnome-shell-plugin.c
index 5364f043a0..537487bacb 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 0ccdb10299..6905a52b99 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]