Re: Roundtrip in gdk_flush()
- From: Soeren Sandmann <sandmann daimi au dk>
- To: Owen Taylor <otaylor redhat com>
- Cc: gtk-devel-list gnome org
- Subject: Re: Roundtrip in gdk_flush()
- Date: 25 Mar 2002 20:25:37 +0100
Owen Taylor <otaylor redhat com> writes:
> I think except on SMP machines, the 25% in gdk_flush() doesn't
> indicate any real problems... we are just waiting for the X server to
> catch up. (Even in SMP cases, I don't think there is any point in
> getting ahead of the X server; we'd just end up blocking with full
> request queues a little later anyways.)
Well, I did some tests:
I instrumented gtk with this patch to gtkcontainer.c:
alpine:~/vertigo/gtk+/gtk% cvs diff -u gtkcontainer.c
Index: gtkcontainer.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkcontainer.c,v
retrieving revision 1.107
diff -u -r1.107 gtkcontainer.c
--- gtkcontainer.c 20 Mar 2002 21:47:00 -0000 1.107
+++ gtkcontainer.c 25 Mar 2002 19:24:40 -0000
@@ -976,6 +976,10 @@
return GTK_IS_RESIZE_CONTAINER (widget) ? (GtkContainer*) widget : NULL;
}
+static GTimer *timer = NULL;
+static gdouble total = 0.0;
+static guint n_resizes = 0;
+
static gboolean
gtk_container_idle_sizer (gpointer data)
{
@@ -1003,6 +1007,9 @@
gdk_window_process_all_updates ();
+ total += g_timer_elapsed (timer, NULL);
+ g_print ("time to resize: %f\n", total / ++n_resizes);
+
GDK_THREADS_LEAVE ();
return FALSE;
@@ -1041,9 +1048,16 @@
{
GTK_PRIVATE_SET_FLAG (resize_container, GTK_RESIZE_PENDING);
if (container_resize_queue == NULL)
- gtk_idle_add_priority (GTK_PRIORITY_RESIZE,
+ {
+ if (!timer)
+ timer = g_timer_new ();
+
+ g_timer_reset (timer);
+
+ gtk_idle_add_priority (GTK_PRIORITY_RESIZE,
gtk_container_idle_sizer,
NULL);
+ }
container_resize_queue = g_slist_prepend (container_resize_queue, resize_container);
}
break;
and then I tried opaque resizing the notebook test in testgtk.c with
various implementations of gdk_flush():
(a) Unmodified gtk+ with gdk_flush() == XSync (): 0.019730
(b) gtk with gdk_flush() == XFlush(): 0.005460
(c) with gdk_window_process_all_updates() calling XFlush() 0.005903
(d) calling gdk_flush() == XSync in idle handler 0.005445
So it seems that getting rid of the round trip does have a significant
impact on the time to respond to events.
Søren
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]