1 | /* GDK - The GIMP Drawing Kit |
2 | * Copyright (C) 2018 Red Hat, Inc. |
3 | * |
4 | * This library is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Lesser General Public |
6 | * License as published by the Free Software Foundation; either |
7 | * version 2 of the License, or (at your option) any later version. |
8 | * |
9 | * This library is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | * Lesser General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU Lesser General Public |
15 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
16 | */ |
17 | |
18 | #ifndef __GDK_PROFILER_PRIVATE_H__ |
19 | #define __GDK_PROFILER_PRIVATE_H__ |
20 | |
21 | #include "gdk/gdkframeclock.h" |
22 | #include "gdk/gdkdisplay.h" |
23 | |
24 | /* Ensure we included config.h as needed for the below HAVE_SYSPROF_CAPTURE check */ |
25 | #ifndef GETTEXT_PACKAGE |
26 | #error "config.h was not included before gdkprofilerprivate.h." |
27 | #endif |
28 | |
29 | #ifdef HAVE_SYSPROF |
30 | #include <sysprof-capture.h> |
31 | #endif |
32 | |
33 | G_BEGIN_DECLS |
34 | |
35 | #ifdef HAVE_SYSPROF |
36 | #define GDK_PROFILER_IS_RUNNING (gdk_profiler_is_running ()) |
37 | #define GDK_PROFILER_CURRENT_TIME SYSPROF_CAPTURE_CURRENT_TIME |
38 | #else |
39 | #define GDK_PROFILER_IS_RUNNING 0 |
40 | #define GDK_PROFILER_CURRENT_TIME 0 |
41 | #endif |
42 | |
43 | gboolean gdk_profiler_is_running (void); |
44 | |
45 | /* Note: Times and durations are in nanoseconds; |
46 | * g_get_monotonic_time(), and GdkFrameClock times |
47 | * are in microseconds, so multiply by 1000. |
48 | */ |
49 | void gdk_profiler_add_mark (gint64 begin_time, |
50 | gint64 duration, |
51 | const gchar *name, |
52 | const gchar *message); |
53 | void gdk_profiler_add_markf (gint64 begin_time, |
54 | gint64 duration, |
55 | const gchar *name, |
56 | const gchar *message_format, |
57 | ...) G_GNUC_PRINTF (4, 5); |
58 | void gdk_profiler_end_mark (gint64 begin_time, |
59 | const gchar *name, |
60 | const gchar *message); |
61 | void gdk_profiler_end_markf (gint64 begin_time, |
62 | const gchar *name, |
63 | const gchar *message_format, |
64 | ...) G_GNUC_PRINTF (3, 4); |
65 | |
66 | guint gdk_profiler_define_counter (const char *name, |
67 | const char *description); |
68 | guint gdk_profiler_define_int_counter (const char *name, |
69 | const char *description); |
70 | void gdk_profiler_set_counter (guint id, |
71 | double value); |
72 | void gdk_profiler_set_int_counter (guint id, |
73 | gint64 value); |
74 | |
75 | #ifndef HAVE_SYSPROF |
76 | #define gdk_profiler_add_mark(b, d, n, m) G_STMT_START {} G_STMT_END |
77 | #define gdk_profiler_end_mark(b, n, m) G_STMT_START {} G_STMT_END |
78 | /* Optimise the whole call out */ |
79 | #if defined(G_HAVE_ISO_VARARGS) |
80 | #define gdk_profiler_add_markf(b, d, n, m, ...) G_STMT_START {} G_STMT_END |
81 | #define gdk_profiler_end_markf(b, n, m, ...) G_STMT_START {} G_STMT_END |
82 | #elif defined(G_HAVE_GNUC_VARARGS) |
83 | #define gdk_profiler_add_markf(b, d, n, m...) G_STMT_START {} G_STMT_END |
84 | #define gdk_profiler_end_markf(b, n, m...) G_STMT_START {} G_STMT_END |
85 | #else |
86 | /* no varargs macro support; the call will have to be optimised out by the compiler */ |
87 | #endif |
88 | |
89 | #define gdk_profiler_define_counter(n, d) 0 |
90 | #define gdk_profiler_define_int_counter(n, d) 0 |
91 | #define gdk_profiler_set_counter(i, v) G_STMT_START {} G_STMT_END |
92 | #define gdk_profiler_set_int_counter(i, v) G_STMT_START {} G_STMT_END |
93 | #endif |
94 | |
95 | G_END_DECLS |
96 | |
97 | #endif /* __GDK_PROFILER_PRIVATE_H__ */ |
98 | |