[gtk/wip/otte/sortlistmodel: 28/38] sor3listmodel: Add profiler marks
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/sortlistmodel: 28/38] sor3listmodel: Add profiler marks
- Date: Tue, 21 Jul 2020 14:42:07 +0000 (UTC)
commit c11942331ef5798fb15da587239894c21c6c5d5b
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Jul 11 10:44:39 2020 -0400
sor3listmodel: Add profiler marks
gtk/gtksor3listmodel.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
---
diff --git a/gtk/gtksor3listmodel.c b/gtk/gtksor3listmodel.c
index c1e3425376..d2e0b99021 100644
--- a/gtk/gtksor3listmodel.c
+++ b/gtk/gtksor3listmodel.c
@@ -23,6 +23,7 @@
#include "gtkintl.h"
#include "gtkprivate.h"
+#include "gdk/gdkprofilerprivate.h"
#define GDK_ARRAY_ELEMENT_TYPE GObject *
#define GDK_ARRAY_TYPE_NAME SortArray
@@ -98,6 +99,8 @@ struct _GtkSor3ListModel
guint sorting_cb;
guint sorted_to;
PivotStack stack;
+
+ gint64 start_time;
};
struct _GtkSor3ListModelClass
@@ -181,6 +184,16 @@ gtk_sor3_list_model_stop_sorting (GtkSor3ListModel *self)
g_clear_handle_id (&self->sorting_cb, g_source_remove);
pivot_stack_set_size (&self->stack, 0);
+ if (GDK_PROFILER_IS_RUNNING)
+ {
+ guint n_items = g_list_model_get_n_items (G_LIST_MODEL (self));
+
+ if (self->start_time != 0)
+ gdk_profiler_add_markf (self->start_time, g_get_monotonic_time () - self->start_time, "sort",
"sorting %u", n_items);
+
+ self->start_time = 0;
+ }
+
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SORTING]);
}
@@ -266,6 +279,7 @@ gtk_sor3_list_model_sort_cb (gpointer data)
guint end;
guint n_items;
guint i;
+ gint64 begin = g_get_monotonic_time ();
start = self->sorted_to;
n_items = sort_array_get_size (&self->items);
@@ -282,6 +296,9 @@ gtk_sor3_list_model_sort_cb (gpointer data)
g_list_model_items_changed (G_LIST_MODEL (self), start, n_items - start, n_items - start);
+ if (GDK_PROFILER_IS_RUNNING)
+ gdk_profiler_add_markf (begin, g_get_monotonic_time () - begin, "sort", "sort step (%u:%u)", start,
n_items);
+
return G_SOURCE_CONTINUE;
}
@@ -294,6 +311,8 @@ gtk_sor3_list_model_start_sorting (GtkSor3ListModel *self)
g_assert (pivot_stack_get_size (&self->stack) == 0);
g_assert (self->sorting_cb == 0);
+ self->start_time = g_get_monotonic_time ();
+
pivot_stack_push (&self->stack, (guint)sort_array_get_size (&self->items) - 1);
self->sorted_to = 0;
@@ -306,8 +325,13 @@ gtk_sor3_list_model_start_sorting (GtkSor3ListModel *self)
static void
gtk_sor3_list_model_resort (GtkSor3ListModel *self)
{
+ guint64 begin = g_get_monotonic_time ();
+
gtk_sor3_list_model_stop_sorting (self);
gtk_sor3_list_model_start_sorting (self);
+
+ if (GDK_PROFILER_IS_RUNNING)
+ gdk_profiler_add_mark (begin, g_get_monotonic_time () - begin, "resort", NULL);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]