icon-theme: Improve profiler mark for icon loads
authorAlexander Larsson <alexl@redhat.com>
Wed, 29 Jan 2020 10:33:30 +0000 (11:33 +0100)
committerAlexander Larsson <alexl@redhat.com>
Thu, 30 Jan 2020 09:53:43 +0000 (10:53 +0100)
This adds the actual time it took to them as well as the icon size
and scale.

gtk/gtkicontheme.c

index 3822b9b69bbc5f711f6ea42e9e8b67d8e2ded89f..e354f8c4fdb5572f0fc3f9a4e0bf718089c2236e 100644 (file)
@@ -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;
 }