[gtk/tracing] Add an api for inserting profiling marks
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/tracing] Add an api for inserting profiling marks
- Date: Mon, 6 May 2019 21:25:30 +0000 (UTC)
commit dff4113e9f43aefd1e6c33e26f36934b4f3dd402
Author: Matthias Clasen <mclasen redhat com>
Date: Mon May 6 21:12:30 2019 +0000
Add an api for inserting profiling marks
This is useful to mark interesting events
in the profiler.
docs/reference/gdk/gdk4-sections.txt | 3 +++
gdk/gdk.h | 1 +
gdk/gdkprofiler.c | 33 +++++++++++++++++++++++++++++++++
gdk/gdkprofiler.h | 32 ++++++++++++++++++++++++++++++++
4 files changed, 69 insertions(+)
---
diff --git a/docs/reference/gdk/gdk4-sections.txt b/docs/reference/gdk/gdk4-sections.txt
index 8eb27f7c89..d78790e343 100644
--- a/docs/reference/gdk/gdk4-sections.txt
+++ b/docs/reference/gdk/gdk4-sections.txt
@@ -17,6 +17,9 @@ GDK_VERSION_MIN_REQUIRED
GDK_VERSION_MAX_ALLOWED
GDK_DISABLE_DEPRECATION_WARNINGS
+<SUBSECTION Profiling>
+gdk_profiler_set_mark
+
<SUBSECTION Standard>
GDK_TYPE_GRAB_STATUS
diff --git a/gdk/gdk.h b/gdk/gdk.h
index a537ed341f..d3baac51de 100644
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -60,6 +60,7 @@
#include <gdk/gdkpaintable.h>
#include <gdk/gdkpango.h>
#include <gdk/gdkpixbuf.h>
+#include <gdk/gdkprofiler.h>
#include <gdk/gdkproperty.h>
#include <gdk/gdkrectangle.h>
#include <gdk/gdkrgba.h>
diff --git a/gdk/gdkprofiler.c b/gdk/gdkprofiler.c
index b8d23d2042..eab63836cb 100644
--- a/gdk/gdkprofiler.c
+++ b/gdk/gdkprofiler.c
@@ -23,7 +23,9 @@
#include <sys/types.h>
#include <unistd.h>
+#include "gdkversionmacros.h"
#include "capture/sp-capture-writer.h"
+#include "gdkprofiler.h"
#include "gdkprofilerprivate.h"
#include "gdkframeclockprivate.h"
@@ -90,6 +92,37 @@ gdk_profiler_add_mark (gint64 start,
"gtk", name, message);
}
+/**
+ * gdk_profiler_set_mark:
+ * @duration: the duration of the mark, or 0
+ * @name: the name of the mark (up to 40 characters)
+ * @message: (optional): the message of the mark
+ *
+ * Insert a mark into the profiling data if we
+ * are currently profiling.
+ * This information will show up in tools like sysprof
+ * or GNOME Builder when viewing the profiling data.
+ * It can be used to mark interesting regions in the
+ * captured data.
+ *
+ * If the duration is non-zero, the mark applies to
+ * the timespan from @duration microseconds in the
+ * past to the current time. To mark just a point in
+ * time, pass 0 as duration.
+ *
+ * @name should be a short string, and @message is optional.
+ */
+void
+gdk_profiler_set_mark (guint64 duration,
+ const char *name,
+ const char *message)
+{
+ guint64 start;
+
+ start = g_get_monotonic_time () - duration;
+ gdk_profiler_add_mark (start, duration, name, message);
+}
+
static guint
define_counter (const char *name,
const char *description,
diff --git a/gdk/gdkprofiler.h b/gdk/gdkprofiler.h
new file mode 100644
index 0000000000..70c283df9e
--- /dev/null
+++ b/gdk/gdkprofiler.h
@@ -0,0 +1,32 @@
+/* GDK - The GIMP Drawing Kit
+ * Copyright (C) 2018 Red Hat, Inc.
+ *
+ * This library 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 of the License, or (at your option) any later version.
+ *
+ * This library 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/>.
+ */
+
+#ifndef __GDK_PROFILER_H__
+#define __GDK_PROFILER_H__
+
+#include <gdk/gdkversionmacros.h>
+
+G_BEGIN_DECLS
+
+GDK_AVAILABLE_IN_ALL
+void gdk_profiler_set_mark (guint64 duration,
+ const char *name,
+ const char *message);
+
+G_END_DECLS
+
+#endif /* __GDK_PROFILER_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]