[gnome-software] Output detailed profiling when navigating through application shells
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Output detailed profiling when navigating through application shells
- Date: Wed, 14 Sep 2016 12:44:20 +0000 (UTC)
commit a89726124b83e63f84d77132c70ade7bc5c7508b
Author: Richard Hughes <richard hughsie com>
Date: Wed Sep 14 13:26:50 2016 +0100
Output detailed profiling when navigating through application shells
src/gs-application.c | 7 +++++
src/gs-shell-category.c | 3 ++
src/gs-shell-details.c | 3 ++
src/gs-shell-extras.c | 3 ++
src/gs-shell-installed.c | 3 ++
src/gs-shell-moderate.c | 3 ++
src/gs-shell-overview.c | 57 +++++++++++++++++++++++++---------------------
src/gs-shell-search.c | 3 ++
src/gs-shell-updates.c | 32 +++++++++++++++++++------
src/gs-shell.c | 21 +++++++++++++++++
src/gs-shell.h | 3 ++
11 files changed, 104 insertions(+), 34 deletions(-)
---
diff --git a/src/gs-application.c b/src/gs-application.c
index 3c1453c..a15fe92 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -52,6 +52,7 @@
struct _GsApplication {
GtkApplication parent;
+ gboolean enable_profile_mode;
GCancellable *cancellable;
GtkApplication *application;
GtkCssProvider *provider;
@@ -319,6 +320,9 @@ gs_application_initialize_ui (GsApplication *app)
/* setup UI */
app->shell = gs_shell_new ();
+ /* this lets gs_shell_profile_dump() work from shells */
+ gs_shell_set_profile_mode (app->shell, app->enable_profile_mode);
+
app->cancellable = g_cancellable_new ();
gs_shell_setup (app->shell, app->plugin_loader, app->cancellable);
@@ -397,6 +401,9 @@ profile_activated (GSimpleAction *action,
gpointer data)
{
GsApplication *app = GS_APPLICATION (data);
+ app->enable_profile_mode = TRUE;
+
+ /* dump right now as well */
if (app->plugin_loader != NULL) {
AsProfile *profile = gs_plugin_loader_get_profile (app->plugin_loader);
as_profile_dump (profile);
diff --git a/src/gs-shell-category.c b/src/gs-shell-category.c
index 783ab4e..66de874 100644
--- a/src/gs-shell-category.c
+++ b/src/gs-shell-category.c
@@ -104,6 +104,9 @@ gs_shell_category_get_apps_cb (GObject *source_object,
gtk_container_add (GTK_CONTAINER (self->category_detail_box), tile);
gtk_widget_set_can_focus (gtk_widget_get_parent (tile), FALSE);
}
+
+ /* seems a good place */
+ gs_shell_profile_dump (self->shell);
}
static void
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index eb54cd7..ffb9d98 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -1286,6 +1286,9 @@ gs_shell_details_app_refine2_cb (GObject *source,
return;
}
gs_shell_details_refresh_reviews (self);
+
+ /* seems a good place */
+ gs_shell_profile_dump (self->shell);
}
static void
diff --git a/src/gs-shell-extras.c b/src/gs-shell-extras.c
index b379ffb..73eafa7 100644
--- a/src/gs-shell-extras.c
+++ b/src/gs-shell-extras.c
@@ -507,6 +507,9 @@ show_search_results (GsShellExtras *self)
gs_shell_extras_set_state (self,
GS_SHELL_EXTRAS_STATE_READY);
}
+
+ /* seems a good place */
+ gs_shell_profile_dump (self->shell);
}
static void
diff --git a/src/gs-shell-installed.c b/src/gs-shell-installed.c
index 8847fe5..1a739bc 100644
--- a/src/gs-shell-installed.c
+++ b/src/gs-shell-installed.c
@@ -221,6 +221,9 @@ gs_shell_installed_get_installed_cb (GObject *source_object,
}
out:
gs_shell_installed_pending_apps_changed_cb (plugin_loader, self);
+
+ /* seems a good place */
+ gs_shell_profile_dump (self->shell);
}
static void
diff --git a/src/gs-shell-moderate.c b/src/gs-shell-moderate.c
index ab3023e..a62bdd3 100644
--- a/src/gs-shell-moderate.c
+++ b/src/gs-shell-moderate.c
@@ -168,6 +168,9 @@ gs_shell_moderate_get_unvoted_reviews_cb (GObject *source_object,
app = gs_app_list_index (list, i);
gs_shell_moderate_add_app (self, app);
}
+
+ /* seems a good place */
+ gs_shell_profile_dump (self->shell);
}
static void
diff --git a/src/gs-shell-overview.c b/src/gs-shell-overview.c
index 1d64135..b2d9bd8 100644
--- a/src/gs-shell-overview.c
+++ b/src/gs-shell-overview.c
@@ -44,7 +44,7 @@ typedef struct
GCancellable *cancellable;
gboolean cache_valid;
GsShell *shell;
- gint refresh_count;
+ gint action_cnt;
gboolean loading_featured;
gboolean loading_popular;
gboolean loading_popular_rotating;
@@ -124,6 +124,27 @@ filter_category (GsApp *app, gpointer user_data)
}
static void
+gs_shell_overview_decrement_action_cnt (GsShellOverview *self)
+{
+ GsShellOverviewPrivate *priv = gs_shell_overview_get_instance_private (self);
+
+ /* every job increcements this */
+ if (priv->action_cnt == 0) {
+ g_warning ("action_cnt already zero!");
+ return;
+ }
+ if (--priv->action_cnt > 0)
+ return;
+
+ /* all done */
+ priv->cache_valid = TRUE;
+ g_signal_emit (self, signals[SIGNAL_REFRESHED], 0);
+
+ /* seems a good place */
+ gs_shell_profile_dump (priv->shell);
+}
+
+static void
gs_shell_overview_get_popular_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
@@ -164,11 +185,7 @@ gs_shell_overview_get_popular_cb (GObject *source_object,
out:
priv->loading_popular = FALSE;
- priv->refresh_count--;
- if (priv->refresh_count == 0) {
- priv->cache_valid = TRUE;
- g_signal_emit (self, signals[SIGNAL_REFRESHED], 0);
- }
+ gs_shell_overview_decrement_action_cnt (self);
}
static void
@@ -275,11 +292,7 @@ gs_shell_overview_get_category_apps_cb (GObject *source_object,
out:
load_data_free (load_data);
priv->loading_popular_rotating = FALSE;
- priv->refresh_count--;
- if (priv->refresh_count == 0) {
- priv->cache_valid = TRUE;
- g_signal_emit (self, signals[SIGNAL_REFRESHED], 0);
- }
+ gs_shell_overview_decrement_action_cnt (self);
}
static void
@@ -329,11 +342,7 @@ gs_shell_overview_get_featured_cb (GObject *source_object,
out:
priv->loading_featured = FALSE;
- priv->refresh_count--;
- if (priv->refresh_count == 0) {
- priv->cache_valid = TRUE;
- g_signal_emit (self, signals[SIGNAL_REFRESHED], 0);
- }
+ gs_shell_overview_decrement_action_cnt (self);
}
static void
@@ -406,11 +415,7 @@ out:
gtk_widget_set_visible (priv->category_heading, added_cnt > 0);
priv->loading_categories = FALSE;
- priv->refresh_count--;
- if (priv->refresh_count == 0) {
- priv->cache_valid = TRUE;
- g_signal_emit (self, signals[SIGNAL_REFRESHED], 0);
- }
+ gs_shell_overview_decrement_action_cnt (self);
}
static const gchar *
@@ -489,7 +494,7 @@ gs_shell_overview_load (GsShellOverview *self)
priv->cancellable,
gs_shell_overview_get_featured_cb,
self);
- priv->refresh_count++;
+ priv->action_cnt++;
}
if (!priv->loading_popular) {
@@ -500,7 +505,7 @@ gs_shell_overview_load (GsShellOverview *self)
priv->cancellable,
gs_shell_overview_get_popular_cb,
self);
- priv->refresh_count++;
+ priv->action_cnt++;
}
if (!priv->loading_popular_rotating) {
@@ -535,7 +540,7 @@ gs_shell_overview_load (GsShellOverview *self)
priv->cancellable,
gs_shell_overview_get_category_apps_cb,
load_data);
- priv->refresh_count++;
+ priv->action_cnt++;
}
priv->loading_popular_rotating = TRUE;
}
@@ -547,7 +552,7 @@ gs_shell_overview_load (GsShellOverview *self)
priv->cancellable,
gs_shell_overview_get_categories_cb,
self);
- priv->refresh_count++;
+ priv->action_cnt++;
}
}
@@ -592,7 +597,7 @@ gs_shell_overview_switch_to (GsPage *page, gboolean scroll_up)
gs_grab_focus_when_mapped (priv->scrolledwindow_overview);
- if (priv->cache_valid || priv->refresh_count > 0)
+ if (priv->cache_valid || priv->action_cnt > 0)
return;
gs_shell_overview_load (self);
}
diff --git a/src/gs-shell-search.c b/src/gs-shell-search.c
index 9edd794..b82d956 100644
--- a/src/gs-shell-search.c
+++ b/src/gs-shell-search.c
@@ -154,6 +154,9 @@ gs_shell_search_get_search_cb (GObject *source_object,
gs_shell_show_app (self->shell, a);
g_clear_pointer (&self->appid_to_show, g_free);
}
+
+ /* seems a good place */
+ gs_shell_profile_dump (self->shell);
}
static gboolean
diff --git a/src/gs-shell-updates.c b/src/gs-shell-updates.c
index ea9f4a7..7c73cc0 100644
--- a/src/gs-shell-updates.c
+++ b/src/gs-shell-updates.c
@@ -74,7 +74,7 @@ struct _GsShellUpdates
GSettings *settings;
GSettings *desktop_settings;
gboolean cache_valid;
- guint in_flight;
+ guint action_cnt;
gboolean all_updates_are_live;
gboolean any_require_reboot;
GsShell *shell;
@@ -445,6 +445,24 @@ gs_shell_updates_set_state (GsShellUpdates *self, GsShellUpdatesState state)
}
static void
+gs_shell_updates_decrement_refresh_count (GsShellUpdates *self)
+{
+ /* every job increcements this */
+ if (self->action_cnt == 0) {
+ g_warning ("action_cnt already zero!");
+ return;
+ }
+ if (--self->action_cnt > 0)
+ return;
+
+ /* all done */
+ gs_shell_updates_set_state (self, GS_SHELL_UPDATES_STATE_IDLE);
+
+ /* seems a good place */
+ gs_shell_profile_dump (self->shell);
+}
+
+static void
gs_shell_updates_notify_network_state_cb (GNetworkMonitor *network_monitor,
gboolean available,
GsShellUpdates *self)
@@ -533,8 +551,7 @@ gs_shell_updates_get_updates_cb (GsPluginLoader *plugin_loader,
}
/* only when both set */
- if (--self->in_flight == 0)
- gs_shell_updates_set_state (self, GS_SHELL_UPDATES_STATE_IDLE);
+ gs_shell_updates_decrement_refresh_count (self);
}
static void
@@ -565,8 +582,7 @@ gs_shell_updates_get_upgrades_cb (GObject *source_object,
}
/* only when both set */
- if (--self->in_flight == 0)
- gs_shell_updates_set_state (self, GS_SHELL_UPDATES_STATE_IDLE);
+ gs_shell_updates_decrement_refresh_count (self);
}
static void
@@ -574,7 +590,7 @@ gs_shell_updates_load (GsShellUpdates *self)
{
guint64 refine_flags;
- if (self->in_flight > 0)
+ if (self->action_cnt > 0)
return;
gs_container_remove_all (GTK_CONTAINER (self->list_box_updates));
refine_flags = GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON |
@@ -583,7 +599,7 @@ gs_shell_updates_load (GsShellUpdates *self)
GS_PLUGIN_REFINE_FLAGS_REQUIRE_VERSION;
gs_shell_updates_set_state (self,
GS_SHELL_UPDATES_STATE_ACTION_GET_UPDATES);
- self->in_flight++;
+ self->action_cnt++;
gs_plugin_loader_get_updates_async (self->plugin_loader,
refine_flags,
self->cancellable,
@@ -598,7 +614,7 @@ gs_shell_updates_load (GsShellUpdates *self)
self->cancellable,
gs_shell_updates_get_upgrades_cb,
self);
- self->in_flight++;
+ self->action_cnt++;
}
}
diff --git a/src/gs-shell.c b/src/gs-shell.c
index d9ac7ec..9b846c3 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -86,6 +86,7 @@ typedef struct
GPtrArray *modal_dialogs;
gulong search_changed_id;
gchar *events_info_uri;
+ gboolean profile_mode;
} GsShellPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (GsShell, gs_shell, G_TYPE_OBJECT)
@@ -154,6 +155,26 @@ gs_shell_activate (GsShell *shell)
gtk_window_present (priv->main_window);
}
+void
+gs_shell_profile_dump (GsShell *shell)
+{
+ GsShellPrivate *priv = gs_shell_get_instance_private (shell);
+ if (priv->profile_mode) {
+ AsProfile *profile = gs_plugin_loader_get_profile (priv->plugin_loader);
+#if AS_CHECK_VERSION(0,6,4)
+ as_profile_prune (profile, 5000);
+#endif
+ as_profile_dump (profile);
+ }
+}
+
+void
+gs_shell_set_profile_mode (GsShell *shell, gboolean profile_mode)
+{
+ GsShellPrivate *priv = gs_shell_get_instance_private (shell);
+ priv->profile_mode = profile_mode;
+}
+
static void
gs_shell_set_header_start_widget (GsShell *shell, GtkWidget *widget)
{
diff --git a/src/gs-shell.h b/src/gs-shell.h
index 6052ddb..cb2c303 100644
--- a/src/gs-shell.h
+++ b/src/gs-shell.h
@@ -58,6 +58,7 @@ typedef enum {
GsShell *gs_shell_new (void);
void gs_shell_activate (GsShell *shell);
+void gs_shell_profile_dump (GsShell *shell);
void gs_shell_refresh (GsShell *shell,
GCancellable *cancellable);
void gs_shell_change_mode (GsShell *shell,
@@ -66,6 +67,8 @@ void gs_shell_change_mode (GsShell *shell,
gboolean scroll_up);
void gs_shell_set_mode (GsShell *shell,
GsShellMode mode);
+void gs_shell_set_profile_mode (GsShell *shell,
+ gboolean profile_mode);
void gs_shell_modal_dialog_present (GsShell *shell,
GtkDialog *dialog);
GsShellMode gs_shell_get_mode (GsShell *shell);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]