forked from AuroraMiddleware/gtk
profiler: Add _end_mark() version of _add_mark()
These don't take a duration, instead they call g_get_monotonic_time() to and subtract the start time for it. Almost all our calls are like this, and this makes the callsites clearer and avoids inlining the clock call into the call site.
This commit is contained in:
parent
01d5ad2056
commit
2890cd849f
@ -652,10 +652,7 @@ _gdk_frame_clock_emit_flush_events (GdkFrameClock *frame_clock)
|
||||
g_signal_emit (frame_clock, signals[FLUSH_EVENTS], 0);
|
||||
|
||||
if (GDK_PROFILER_IS_RUNNING)
|
||||
{
|
||||
gint64 after = g_get_monotonic_time ();
|
||||
gdk_profiler_add_mark (before, (after - before), "frameclock", "flush-events");
|
||||
}
|
||||
gdk_profiler_end_mark (before, "frameclock", "flush-events");
|
||||
}
|
||||
|
||||
void
|
||||
@ -666,10 +663,7 @@ _gdk_frame_clock_emit_before_paint (GdkFrameClock *frame_clock)
|
||||
g_signal_emit (frame_clock, signals[BEFORE_PAINT], 0);
|
||||
|
||||
if (GDK_PROFILER_IS_RUNNING)
|
||||
{
|
||||
gint64 after = g_get_monotonic_time ();
|
||||
gdk_profiler_add_mark (before, (after - before), "frameclock", "before-paint");
|
||||
}
|
||||
gdk_profiler_end_mark (before, "frameclock", "before-paint");
|
||||
}
|
||||
|
||||
void
|
||||
@ -680,10 +674,7 @@ _gdk_frame_clock_emit_update (GdkFrameClock *frame_clock)
|
||||
g_signal_emit (frame_clock, signals[UPDATE], 0);
|
||||
|
||||
if (GDK_PROFILER_IS_RUNNING)
|
||||
{
|
||||
gint64 after = g_get_monotonic_time ();
|
||||
gdk_profiler_add_mark (before, (after - before), "frameclock", "update");
|
||||
}
|
||||
gdk_profiler_end_mark (before, "frameclock", "update");
|
||||
}
|
||||
|
||||
void
|
||||
@ -694,10 +685,7 @@ _gdk_frame_clock_emit_layout (GdkFrameClock *frame_clock)
|
||||
g_signal_emit (frame_clock, signals[LAYOUT], 0);
|
||||
|
||||
if (GDK_PROFILER_IS_RUNNING)
|
||||
{
|
||||
gint64 after = g_get_monotonic_time ();
|
||||
gdk_profiler_add_mark (before, (after - before), "frameclock", "layout");
|
||||
}
|
||||
gdk_profiler_end_mark (before, "frameclock", "layout");
|
||||
}
|
||||
|
||||
void
|
||||
@ -708,10 +696,7 @@ _gdk_frame_clock_emit_paint (GdkFrameClock *frame_clock)
|
||||
g_signal_emit (frame_clock, signals[PAINT], 0);
|
||||
|
||||
if (GDK_PROFILER_IS_RUNNING)
|
||||
{
|
||||
gint64 after = g_get_monotonic_time ();
|
||||
gdk_profiler_add_mark (before, (after - before), "frameclock", "paint");
|
||||
}
|
||||
gdk_profiler_end_mark (before, "frameclock", "paint");
|
||||
}
|
||||
|
||||
void
|
||||
@ -722,10 +707,7 @@ _gdk_frame_clock_emit_after_paint (GdkFrameClock *frame_clock)
|
||||
g_signal_emit (frame_clock, signals[AFTER_PAINT], 0);
|
||||
|
||||
if (GDK_PROFILER_IS_RUNNING)
|
||||
{
|
||||
gint64 after = g_get_monotonic_time ();
|
||||
gdk_profiler_add_mark (before, (after - before), "frameclock", "after-paint");
|
||||
}
|
||||
gdk_profiler_end_mark (before, "frameclock", "after-paint");
|
||||
}
|
||||
|
||||
void
|
||||
@ -736,10 +718,7 @@ _gdk_frame_clock_emit_resume_events (GdkFrameClock *frame_clock)
|
||||
g_signal_emit (frame_clock, signals[RESUME_EVENTS], 0);
|
||||
|
||||
if (GDK_PROFILER_IS_RUNNING)
|
||||
{
|
||||
gint64 after = g_get_monotonic_time ();
|
||||
gdk_profiler_add_mark (before, (after - before), "frameclock", "resume-events");
|
||||
}
|
||||
gdk_profiler_end_mark (before, "frameclock", "resume-events");
|
||||
}
|
||||
|
||||
static gint64
|
||||
|
@ -502,7 +502,7 @@ gdk_frame_clock_paint_idle (void *data)
|
||||
priv->sleep_serial = get_sleep_serial ();
|
||||
|
||||
if (GDK_PROFILER_IS_RUNNING)
|
||||
gdk_profiler_add_mark (before, (g_get_monotonic_time () - before), "frameclock", "paint_idle");
|
||||
gdk_profiler_end_mark (before, "frameclock", "paint_idle");
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@ -598,10 +598,8 @@ gdk_frame_clock_idle_thaw (GdkFrameClock *clock)
|
||||
{
|
||||
if (priv->freeze_time != 0)
|
||||
{
|
||||
gint64 thaw_time = g_get_monotonic_time ();
|
||||
gdk_profiler_add_mark (priv->freeze_time,
|
||||
(thaw_time - priv->freeze_time),
|
||||
"frameclock freeze", "");
|
||||
gdk_profiler_end_mark (priv->freeze_time,
|
||||
"frameclock freeze", NULL);
|
||||
priv->freeze_time = 0;
|
||||
}
|
||||
}
|
||||
|
@ -100,6 +100,23 @@ gdk_profiler_add_mark (gint64 start,
|
||||
"gtk", name, message);
|
||||
}
|
||||
|
||||
static void
|
||||
add_markvf (gint64 start,
|
||||
guint64 duration,
|
||||
const char *name,
|
||||
const char *format,
|
||||
va_list args)
|
||||
{
|
||||
char *message;
|
||||
message = g_strdup_vprintf (format, args);
|
||||
sysprof_capture_writer_add_mark (writer,
|
||||
start * 1000L,
|
||||
-1, getpid (),
|
||||
duration * 1000L,
|
||||
"gtk", name, message);
|
||||
g_free (message);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_profiler_add_markf (gint64 start,
|
||||
guint64 duration,
|
||||
@ -108,23 +125,47 @@ gdk_profiler_add_markf (gint64 start,
|
||||
...)
|
||||
{
|
||||
va_list args;
|
||||
char *message;
|
||||
|
||||
if (!running)
|
||||
return;
|
||||
|
||||
va_start (args, format);
|
||||
message = g_strdup_vprintf (format, args);
|
||||
add_markvf (start, duration, name, format, args);
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_profiler_end_mark (gint64 start,
|
||||
const char *name,
|
||||
const char *message)
|
||||
{
|
||||
if (!running)
|
||||
return;
|
||||
|
||||
sysprof_capture_writer_add_mark (writer,
|
||||
start * 1000L,
|
||||
-1, getpid (),
|
||||
duration * 1000L,
|
||||
(g_get_monotonic_time () - start) * 1000L,
|
||||
"gtk", name, message);
|
||||
g_free (message);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_profiler_end_markf (gint64 start,
|
||||
const char *name,
|
||||
const char *format,
|
||||
...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
if (!running)
|
||||
return;
|
||||
|
||||
va_start (args, format);
|
||||
add_markvf (start, g_get_monotonic_time () - start, name, format, args);
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
|
||||
static guint
|
||||
define_counter (const char *name,
|
||||
const char *description,
|
||||
@ -235,6 +276,21 @@ gdk_profiler_add_markf (gint64 start,
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
gdk_profiler_end_mark (gint64 start,
|
||||
const char *name,
|
||||
const char *message)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
gdk_profiler_end_markf (gint64 start,
|
||||
const char *name,
|
||||
const char *format,
|
||||
...)
|
||||
{
|
||||
}
|
||||
|
||||
guint
|
||||
gdk_profiler_define_counter (const char *name,
|
||||
const char *description)
|
||||
|
@ -50,6 +50,13 @@ void gdk_profiler_add_markf (gint64 start,
|
||||
const char *name,
|
||||
const char *format,
|
||||
...) G_GNUC_PRINTF (4, 5);
|
||||
void gdk_profiler_end_mark (gint64 start,
|
||||
const char *name,
|
||||
const char *message);
|
||||
void gdk_profiler_end_markf (gint64 start,
|
||||
const char *name,
|
||||
const char *format,
|
||||
...) G_GNUC_PRINTF (3, 4);
|
||||
guint gdk_profiler_define_counter (const char *name,
|
||||
const char *description);
|
||||
void gdk_profiler_set_counter (guint id,
|
||||
|
@ -1154,9 +1154,7 @@ _gdk_wayland_display_load_cursor_theme (GdkWaylandDisplay *display_wayland)
|
||||
g_value_unset (&v);
|
||||
|
||||
if (GDK_PROFILER_IS_RUNNING)
|
||||
{
|
||||
gdk_profiler_add_mark (before, (g_get_monotonic_time () - before), "wayland", "load cursor theme");
|
||||
}
|
||||
gdk_profiler_end_mark (before, "wayland", "load cursor theme");
|
||||
|
||||
}
|
||||
|
||||
|
@ -2858,7 +2858,7 @@ gsk_gl_renderer_realize (GskRenderer *renderer,
|
||||
gsk_gl_shadow_cache_init (&self->shadow_cache);
|
||||
|
||||
if (GDK_PROFILER_IS_RUNNING)
|
||||
gdk_profiler_add_mark (before, (g_get_monotonic_time () - before), "gl renderer realize", NULL);
|
||||
gdk_profiler_end_mark (before, "gl renderer realize", NULL);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -307,7 +307,7 @@ gtk_application_startup (GApplication *g_application)
|
||||
before2 = g_get_monotonic_time ();
|
||||
gtk_init ();
|
||||
if (GDK_PROFILER_IS_RUNNING)
|
||||
gdk_profiler_add_mark (before2, (g_get_monotonic_time () - before2), "gtk init", NULL);
|
||||
gdk_profiler_end_mark (before2, "gtk init", NULL);
|
||||
|
||||
priv->impl = gtk_application_impl_new (application, gdk_display_get_default ());
|
||||
gtk_application_impl_startup (priv->impl, priv->register_session);
|
||||
@ -315,7 +315,7 @@ gtk_application_startup (GApplication *g_application)
|
||||
gtk_application_load_resources (application);
|
||||
|
||||
if (GDK_PROFILER_IS_RUNNING)
|
||||
gdk_profiler_add_mark (before, (g_get_monotonic_time () - before), "gtk application startup", NULL);
|
||||
gdk_profiler_end_mark (before, "gtk application startup", NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1625,5 +1625,5 @@ _gtk_builder_parser_parse_buffer (GtkBuilder *builder,
|
||||
/* restore the original domain */
|
||||
gtk_builder_set_translation_domain (builder, domain);
|
||||
|
||||
gdk_profiler_add_mark (before, (g_get_monotonic_time () - before), "builder load", filename);
|
||||
gdk_profiler_end_mark (before, "builder load", filename);
|
||||
}
|
||||
|
@ -1010,7 +1010,7 @@ gtk_css_provider_postprocess (GtkCssProvider *css_provider)
|
||||
#endif
|
||||
|
||||
if (GDK_PROFILER_IS_RUNNING)
|
||||
gdk_profiler_add_mark (before, (g_get_monotonic_time () - before), "create selector tree", NULL);
|
||||
gdk_profiler_end_mark (before, "create selector tree", NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1071,7 +1071,7 @@ gtk_css_provider_load_internal (GtkCssProvider *self,
|
||||
if (GDK_PROFILER_IS_RUNNING)
|
||||
{
|
||||
char *uri = g_file_get_uri (file);
|
||||
gdk_profiler_add_mark (before, (g_get_monotonic_time () - before), "theme load", uri);
|
||||
gdk_profiler_end_mark (before, "theme load", uri);
|
||||
g_free (uri);
|
||||
}
|
||||
}
|
||||
|
@ -477,10 +477,7 @@ populate_emoji_chooser (gpointer data)
|
||||
chooser->populate_idle = 0;
|
||||
|
||||
if (GDK_PROFILER_IS_RUNNING)
|
||||
{
|
||||
now = g_get_monotonic_time ();
|
||||
gdk_profiler_add_mark (start, (now - start), "emojichooser", "populate (finish)");
|
||||
}
|
||||
gdk_profiler_end_mark (start, "emojichooser", "populate (finish)");
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
@ -1847,7 +1847,7 @@ ensure_valid_themes (GtkIconTheme *self,
|
||||
load_themes (self);
|
||||
|
||||
if (GDK_PROFILER_IS_RUNNING)
|
||||
gdk_profiler_add_mark (before, (g_get_monotonic_time () - before), "icon theme load", self->current_theme);
|
||||
gdk_profiler_end_mark (before, "icon theme load", self->current_theme);
|
||||
|
||||
if (was_valid)
|
||||
queue_theme_changed (self);
|
||||
@ -3606,7 +3606,7 @@ icon_ensure_texture__locked (GtkIconPaintable *icon,
|
||||
g_assert (icon->texture != NULL);
|
||||
|
||||
if (GDK_PROFILER_IS_RUNNING)
|
||||
gdk_profiler_add_markf (before, g_get_monotonic_time () - before, in_thread ? "icon load (thread)" : "icon load" ,
|
||||
gdk_profiler_end_markf (before, in_thread ? "icon load (thread)" : "icon load" ,
|
||||
"%s size %d@%d", icon->filename, icon->desired_size, icon->desired_scale);
|
||||
}
|
||||
|
||||
|
@ -12177,8 +12177,8 @@ gtk_widget_render (GtkWidget *widget,
|
||||
GskRenderer *renderer;
|
||||
GskRenderNode *root;
|
||||
int x, y;
|
||||
gint64 before = g_get_monotonic_time ();
|
||||
gint64 after = 0;
|
||||
gint64 before_snapshot = g_get_monotonic_time ();
|
||||
gint64 before_render = 0;
|
||||
|
||||
if (!GTK_IS_NATIVE (widget))
|
||||
return;
|
||||
@ -12195,8 +12195,8 @@ gtk_widget_render (GtkWidget *widget,
|
||||
|
||||
if (GDK_PROFILER_IS_RUNNING)
|
||||
{
|
||||
after = g_get_monotonic_time ();
|
||||
gdk_profiler_add_mark (before, (after - before), "widget snapshot", "");
|
||||
before_render = g_get_monotonic_time ();
|
||||
gdk_profiler_add_mark (before_snapshot, (before_render - before_snapshot), "widget snapshot", "");
|
||||
}
|
||||
|
||||
if (root != NULL)
|
||||
@ -12212,11 +12212,7 @@ gtk_widget_render (GtkWidget *widget,
|
||||
gsk_render_node_unref (root);
|
||||
|
||||
if (GDK_PROFILER_IS_RUNNING)
|
||||
{
|
||||
before = after;
|
||||
after = g_get_monotonic_time ();
|
||||
gdk_profiler_add_mark (before, (after - before), "widget render", "");
|
||||
}
|
||||
gdk_profiler_end_mark (before_render, "widget render", "");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6317,10 +6317,7 @@ gtk_window_check_resize (GtkWindow *self)
|
||||
gtk_window_move_resize (self);
|
||||
|
||||
if (GDK_PROFILER_IS_RUNNING)
|
||||
{
|
||||
gint64 after = g_get_monotonic_time ();
|
||||
gdk_profiler_add_mark (before, (after - before), "size allocation", "");
|
||||
}
|
||||
gdk_profiler_end_mark (before, "size allocation", "");
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user