[gtksourceview] build: add plumbing for sysprof-capture profiling
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview] build: add plumbing for sysprof-capture profiling
- Date: Wed, 23 Sep 2020 01:24:18 +0000 (UTC)
commit 2148d73217bec4e32604aed8d479f146157f5f2d
Author: Christian Hergert <chergert redhat com>
Date: Tue Sep 22 17:12:08 2020 -0700
build: add plumbing for sysprof-capture profiling
This will allow us to do profiling with sysprof-capture-4's collector
interface just like GTK does.
gtksourceview/gtksourcetrace.h | 58 ++++++++++++++++++++++++++++++++++++++++++
gtksourceview/meson.build | 4 +++
meson.build | 24 ++++++++++++++++-
meson_options.txt | 4 +++
4 files changed, 89 insertions(+), 1 deletion(-)
---
diff --git a/gtksourceview/gtksourcetrace.h b/gtksourceview/gtksourcetrace.h
new file mode 100644
index 00000000..afee58f3
--- /dev/null
+++ b/gtksourceview/gtksourcetrace.h
@@ -0,0 +1,58 @@
+/*
+ * This file is part of GtkSourceView
+ *
+ * Copyright 2020 Christian Hergert <chergert redhat com>
+ *
+ * GtkSourceView is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * GtkSourceView 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#pragma once
+
+#include <glib.h>
+
+#ifndef GETTEXT_PACKAGE
+# error "config.h was not included before gtksourcetrace.h."
+#endif
+
+#ifdef HAVE_SYSPROF
+# include <sysprof-capture.h>
+#endif
+
+G_BEGIN_DECLS
+
+#ifdef HAVE_SYSPROF
+# define GTK_SOURCE_PROFILER_BEGIN_MARK \
+ G_STMT_START { \
+ gint64 __begin_time = SYSPROF_CAPTURE_CURRENT_TIME;
+# define GTK_SOURCE_PROFILER_END_MARK(name, message) \
+ G_STMT_START { \
+ gint64 __duration = SYSPROF_CAPTURE_CURRENT_TIME - __begin_time; \
+ sysprof_collector_mark (__begin_time, __duration, "GtkSourceView", name, message); \
+ } G_STMT_END; \
+ } G_STMT_END
+# define GTK_SOURCE_PROFILER_MARK(duration, name, message) \
+ G_STMT_START { \
+ sysprof_collector_mark (SYSPROF_CAPTURE_CURRENT_TIME - duration, \
+ duration, "GtkSourceView", name, message) \
+ } G_STMT_END
+#else
+# define GTK_SOURCE_PROFILER_MARK(duration, name, message) \
+ G_STMT_START { } G_STMT_END
+# define GTK_SOURCE_PROFILER_BEGIN_MARK G_STMT_START {
+# define GTK_SOURCE_PROFILER_END_MARK(name, message) } G_STMT_END
+#endif
+
+G_END_DECLS
diff --git a/gtksourceview/meson.build b/gtksourceview/meson.build
index d7f923a0..d5df1a75 100644
--- a/gtksourceview/meson.build
+++ b/gtksourceview/meson.build
@@ -137,6 +137,10 @@ core_deps = [
fontconfig_dep,
]
+if profiler_enabled
+ core_deps += [libsysprof_capture_dep]
+endif
+
if config_h.has('OS_OSX')
core_c_args += '-xobjective-c'
core_deps += [
diff --git a/meson.build b/meson.build
index 6732eea3..ae334942 100644
--- a/meson.build
+++ b/meson.build
@@ -122,7 +122,7 @@ glib_version_arr = glib_req_version.split('.')
glib_major_version = glib_version_arr[0]
glib_minor_version = glib_version_arr[1]
-# Override until GTK 4 is released
+# XXX: Override until GTK 4 is released
gtk_version_arr = gtk_req_version.split('.')
gtk_major_version = '4' # gtk_version_arr[0]
gtk_minor_version = '0' # gtk_version_arr[1]
@@ -159,6 +159,28 @@ foreach header: check_headers
endif
endforeach
+# libsysprof-capture support
+if get_option('sysprof')
+ libsysprof_capture_dep = dependency('sysprof-capture-4',
+ required: get_option('sysprof'),
+ default_options: [
+ 'enable_examples=false',
+ 'enable_gtk=false',
+ 'enable_tests=false',
+ 'enable_tools=false',
+ 'libsysprof=true',
+ 'with_sysprofd=none',
+ 'help=false',
+ ],
+ fallback: ['sysprof', 'libsysprof_capture_dep'],
+ )
+ config_h.set('HAVE_SYSPROF', libsysprof_capture_dep.found())
+ profiler_enabled = true
+else
+ libsysprof_capture_dep = disabler()
+ profiler_enabled = false
+endif
+
if build_machine.system() == 'darwin' and gtk_quartz_dep.found()
cocoa_dep = dependency('appleframeworks', modules: 'Cocoa', required: false)
assert(cocoa_dep.found(), 'Dependency appleframeworks not found')
diff --git a/meson_options.txt b/meson_options.txt
index 2ded0af0..443f0476 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -13,3 +13,7 @@ option('vapi',
option('gtk_doc',
type: 'boolean', value: false,
description: 'Build reference manual (requires gtk-doc)')
+
+option('sysprof',
+ type: 'boolean', value: false,
+ description: 'Build with sysprof profiler support')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]