[gtk/wip/matthiasc/sortlistmodel: 6/7] tim2sort: Add profiler marks
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/matthiasc/sortlistmodel: 6/7] tim2sort: Add profiler marks
- Date: Sat, 11 Jul 2020 14:51:30 +0000 (UTC)
commit fa68b9c9285c95867b7c5ed4d6e1612c69d758f7
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Jul 11 10:45:28 2020 -0400
tim2sort: Add profiler marks
gtk/gtktim2sortmodel.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
---
diff --git a/gtk/gtktim2sortmodel.c b/gtk/gtktim2sortmodel.c
index 9224916fe6..10f98beba4 100644
--- a/gtk/gtktim2sortmodel.c
+++ b/gtk/gtktim2sortmodel.c
@@ -23,6 +23,7 @@
#include "gtkintl.h"
#include "gtkprivate.h"
+#include "gdk/gdkprofilerprivate.h"
#include "gtktimsortprivate.h"
typedef struct _SortItem SortItem;
@@ -81,6 +82,9 @@ struct _GtkTim2SortModel
GtkTimSort sort; /* ongoing sort operation */
guint sort_cb; /* 0 or current ongoing sort callback */
SortArray items; /* empty if known unsorted */
+
+ gint64 start_time;
+ guint steps;
};
struct _GtkTim2SortModelClass
@@ -151,6 +155,14 @@ gtk_tim2_sort_model_stop_sorting (GtkTim2SortModel *self)
gtk_tim_sort_finish (&self->sort);
g_clear_handle_id (&self->sort_cb, g_source_remove);
+ if (GDK_PROFILER_IS_RUNNING)
+ {
+ if (self->start_time != 0)
+ gdk_profiler_add_markf (self->start_time, g_get_monotonic_time () - self->start_time, "sort",
"sorting %u", (guint)sort_array_get_size (&self->items));
+
+ self->start_time = 0;
+ }
+
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SORTING]);
}
@@ -158,14 +170,22 @@ static gboolean
gtk_tim2_sort_model_sort_cb (gpointer data)
{
GtkTim2SortModel *self = data;
+ gint64 begin = g_get_monotonic_time ();
if (gtk_tim_sort_step (&self->sort))
{
guint n_items = sort_array_get_size (&self->items);
g_list_model_items_changed (G_LIST_MODEL (self), 0, n_items, n_items);
+
+ if (GDK_PROFILER_IS_RUNNING)
+ gdk_profiler_add_markf (begin, g_get_monotonic_time () - begin, "sort", "sort step (%u:%u)", 0,
n_items);
+
return G_SOURCE_CONTINUE;
}
+ if (GDK_PROFILER_IS_RUNNING)
+ gdk_profiler_add_markf (begin, g_get_monotonic_time () - begin, "sort", "sort step (%u:%u)", 0,
(guint)sort_array_get_size (&self->items));
+
gtk_tim2_sort_model_stop_sorting (self);
return G_SOURCE_REMOVE;
}
@@ -178,6 +198,8 @@ gtk_tim2_sort_model_start_sorting (GtkTim2SortModel *self)
self->sort_cb = g_idle_add (gtk_tim2_sort_model_sort_cb, self);
+ self->start_time = g_get_monotonic_time ();
+
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SORTING]);
}
@@ -227,6 +249,9 @@ static void
gtk_tim2_sort_model_resort (GtkTim2SortModel *self,
guint already_sorted)
{
+ if (GDK_PROFILER_IS_RUNNING)
+ gdk_profiler_add_mark (g_get_monotonic_time (), 0, "resort", NULL);
+
if (gtk_tim2_sort_model_is_sorting (self))
{
already_sorted = 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]