[gnome-software] trivial: Add some profiling to try to find the desktop file slowdown



commit 4372f2053902ce08216247ddc18541bbe85a863b
Author: Richard Hughes <richard hughsie com>
Date:   Sun Oct 20 18:55:23 2013 +0100

    trivial: Add some profiling to try to find the desktop file slowdown

 src/gs-profile.c                     |    4 +-
 src/plugins/gs-plugin-datadir-apps.c |   57 +++++++++++++++++++++++++---------
 2 files changed, 44 insertions(+), 17 deletions(-)
---
diff --git a/src/gs-profile.c b/src/gs-profile.c
index 9b1d0b4..efaa827 100644
--- a/src/gs-profile.c
+++ b/src/gs-profile.c
@@ -143,7 +143,7 @@ gs_profile_stop (GsProfile *profile, const gchar *id)
 
        /* debug */
        elapsed_ms = (item->time_stop - item->time_start) / 1000;
-       if (elapsed_ms > 1)
+       if (elapsed_ms > 5)
                g_debug ("%s took %.0fms", id, elapsed_ms);
 
        /* update */
@@ -224,7 +224,7 @@ gs_profile_dump (GsProfile *profile)
        for (i = 0; i < profile->priv->archived->len; i++) {
                item = g_ptr_array_index (profile->priv->archived, i);
                time_ms = (item->time_stop - item->time_start) / 1000;
-               if (time_ms < 2)
+               if (time_ms < 5)
                        continue;
 
                /* print a timechart of what we've done */
diff --git a/src/plugins/gs-plugin-datadir-apps.c b/src/plugins/gs-plugin-datadir-apps.c
index 0d32c31..944c2f5 100644
--- a/src/plugins/gs-plugin-datadir-apps.c
+++ b/src/plugins/gs-plugin-datadir-apps.c
@@ -250,6 +250,41 @@ out:
 }
 
 /**
+ * gs_plugin_refine_app:
+ */
+static gboolean
+gs_plugin_refine_app (GsPlugin *plugin,
+                     GsApp *app,
+                     GsPluginRefineFlags flags,
+                     GCancellable *cancellable,
+                     GError **error)
+{
+       const gchar *fn;
+       gboolean ret = TRUE;
+       gchar *profile_id = NULL;
+
+       /* already set */
+       fn = gs_app_get_metadata_item (app, "DataDir::desktop-filename");
+       if (fn == NULL)
+               goto out;
+       profile_id = g_strdup_printf ("GsPlugin::datadir-apps(refine:%s)",
+                                     gs_app_get_id (app));
+       gs_profile_start (plugin->profile, profile_id);
+       ret = gs_plugin_datadir_apps_extract_desktop_data (plugin, app, fn, error);
+       if (!ret)
+               goto out;
+       gs_profile_stop (plugin->profile, profile_id);
+
+       /* we know it's installed as we read the desktop file */
+       gs_app_set_id_kind (app, GS_APP_ID_KIND_DESKTOP);
+       if (gs_app_get_state (app) == GS_APP_STATE_UNKNOWN)
+               gs_app_set_state (app, GS_APP_STATE_INSTALLED);
+out:
+       g_free (profile_id);
+       return ret;
+}
+
+/**
  * gs_plugin_refine:
  */
 gboolean
@@ -259,21 +294,18 @@ gs_plugin_refine (GsPlugin *plugin,
                  GCancellable *cancellable,
                  GError **error)
 {
-       const gchar *tmp;
-       gboolean ret = TRUE;
-       GList *l;
        GError *error_local = NULL;
+       GList *l;
        GsApp *app;
+       gboolean ret;
 
        for (l = list; l != NULL; l = l->next) {
                app = GS_APP (l->data);
-               tmp = gs_app_get_metadata_item (app, "DataDir::desktop-filename");
-               if (tmp == NULL)
-                       continue;
-               ret = gs_plugin_datadir_apps_extract_desktop_data (plugin,
-                                                                  app,
-                                                                  tmp,
-                                                                  &error_local);
+               ret = gs_plugin_refine_app (plugin,
+                                           app,
+                                           flags,
+                                           cancellable,
+                                           &error_local);
                if (!ret) {
                        if (!g_error_matches (error_local, G_FILE_ERROR, G_FILE_ERROR_NOENT)) {
                                g_warning ("failed to extract desktop data for %s: %s",
@@ -283,11 +315,6 @@ gs_plugin_refine (GsPlugin *plugin,
                        g_clear_error (&error_local);
                        continue;
                }
-
-               /* we know it's installed as we read the desktop file */
-               gs_app_set_id_kind (app, GS_APP_ID_KIND_DESKTOP);
-               if (gs_app_get_state (app) == GS_APP_STATE_UNKNOWN)
-                       gs_app_set_state (app, GS_APP_STATE_INSTALLED);
        }
 
        /* success */


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