gsignal speed



Hi,

Appended program is 12 times slower with GTK 2 than GTK 1.2, 4 times
slower with --enable-threads=no --enable-debug=no for GLib. GTK 1.2
has debug/threads enabled. Adding/removing the gtk_signal_connect()
has no significant effect on speed ratios.

We can't have the checks slowing us down 3x, since we usually leave
them on in the production version. Maybe we can add
G_DISABLE_EXPENSIVE_CHECKS.

Of course, even the 4x slowdown with all checks turned off is
suboptimal.

Havoc

#include <gtk/gtk.h>
#include <time.h>
#include <stdio.h>

#define ITERATIONS 90000
void
my_callback (GtkWidget *widget, GtkRequisition *req, gpointer data)
{
 int i = 1 + 1;

}

int
main (int argc, char** argv)
{
  GtkWidget *widget;
  int i = 0;
  clock_t start;
  clock_t end;
  
  gtk_init (&argc, &argv);

  widget = gtk_widget_new (GTK_TYPE_WIDGET, NULL);

  gtk_signal_connect (GTK_OBJECT (widget), "size_request",
                     GTK_SIGNAL_FUNC (my_callback), NULL);

  start = clock ();
  
  while (i < ITERATIONS)
    {
      GtkRequisition req = { 0, 0 };

      gtk_widget_size_request (widget, &req);
      
      ++i;
    }

  end = clock ();

  printf ("%g seconds\n",
          ((double)end - (double)start) / CLOCKS_PER_SEC);

  return 0;
}





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