#include <gtk/gtk.h>

#define N_WINDOWS 4096

int
main (int argc, char **argv)
{
  GdkWindow *parent;
  GdkWindow *children[N_WINDOWS];
  GdkWindowAttr attributes;
  GTimer *timer;
  int i;

  gtk_init (&argc, &argv);

  attributes.x = 0;
  attributes.y = 0;
  attributes.width = 640;
  attributes.height = 480;
  attributes.window_type = GDK_WINDOW_TOPLEVEL;

  attributes.event_mask = 0;
  attributes.wclass = GDK_INPUT_OUTPUT;

  parent = gdk_window_new (NULL, &attributes,
                           GDK_WA_X | GDK_WA_Y);

  attributes.width = 1;
  attributes.height = 1;
  attributes.window_type = GDK_WINDOW_CHILD;

  for (i = 0; i < N_WINDOWS; i++)
    {
      attributes.x = i;
      children[i] = gdk_window_new (parent, &attributes, GDK_WA_X | GDK_WA_Y);
    }

  timer = g_timer_new ();

  /* Raise each child */
  for (i = 0; i < N_WINDOWS; i++)
    gdk_window_raise (children[i]);

  printf ("time to raise all the children: %f\n",
          g_timer_elapsed (timer, NULL));

  for (i = 0; i < N_WINDOWS; i++)
    gdk_window_destroy (children[i]);

  gdk_window_destroy (parent);

  return 0;
}
