[gtk: 23/40] icon-theme: Improve profiler mark for icon loads



commit d2f26b2f2719c3fa21c0e6cd95b51644fd9d2bbd
Author: Alexander Larsson <alexl redhat com>
Date:   Wed Jan 29 11:33:30 2020 +0100

    icon-theme: Improve profiler mark for icon loads
    
    This adds the actual time it took to them as well as the icon size
    and scale.

 gtk/gtkicontheme.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index 3822b9b69b..e354f8c4fd 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -3662,6 +3662,7 @@ icon_ensure_scale_and_texture__locked (GtkIcon *icon)
   gint scaled_desired_size;
   GdkPixbuf *source_pixbuf;
   gdouble dir_scale;
+  gint64 before;
 
   icon_cache_mark_used_if_cached (icon);
 
@@ -3671,6 +3672,8 @@ icon_ensure_scale_and_texture__locked (GtkIcon *icon)
   if (icon->load_error)
     return FALSE;
 
+  before = g_get_monotonic_time ();
+
   scaled_desired_size = icon->desired_size * icon->desired_scale;
 
   dir_scale = icon->dir_scale;
@@ -3704,8 +3707,6 @@ icon_ensure_scale_and_texture__locked (GtkIcon *icon)
         icon->scale = (gdouble) scaled_desired_size / (icon->dir_size * dir_scale);
     }
 
-  gdk_profiler_add_mark (g_get_monotonic_time () * 1000, 0, "icon load", icon->filename);
-
   /* At this point, we need to actually get the icon; either from the
    * builtin image or by loading the file
    */
@@ -3857,6 +3858,14 @@ icon_ensure_scale_and_texture__locked (GtkIcon *icon)
 
   g_assert (icon->texture != NULL);
 
+
+  if (gdk_profiler_is_running ())
+    {
+      char *message = g_strdup_printf ("%s size %d@%d", icon->filename, icon->desired_size, 
icon->desired_scale);
+      gdk_profiler_add_mark (before * 1000, (g_get_monotonic_time () - before) * 1000, "icon load", message);
+      g_free (message);
+    }
+
   return TRUE;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]