#include <glib-object.h>

gint rounds = 1000000;
gint n = 2;

static gpointer
thread_func (gpointer data)
{
  GObject *o;
  gint i, j;
  gchar *ss;
  GQuark q[14];
  gchar *s[] = {
       "foo",
       "bar",
       "baz",
       "boo",
       "bah",
       "meh",
       "buh",
       "gru",
       "oop",
       "lop",
       "gna",
       "zzz",
       "aua",
       "yyp"
  };


  for (i = 0; i < 14; i++)
    q[i] = g_quark_from_static_string (s[i]);

  o = g_object_new (G_TYPE_OBJECT, NULL);
  for (i = 0; i < rounds; i++)
    {
      ss = "bar";
      for (j = 0; j < 14; j++)
        {
          g_object_set_qdata (o, q[j], ss);
          g_assert (g_object_get_qdata (o, q[j]) == ss);
        }
    }

  return NULL;
}

int
main (int argc, char *argv[])
{
  GTimer *timer;
  gdouble elapsed;
  GThread *thread[10];
  gint i;

  g_type_init ();

  timer = g_timer_new ();

  for (i = 0; i < n; i++)
    thread[i] = g_thread_create (thread_func, NULL, TRUE, NULL);

  for (i = 0; i < n; i++)
    g_thread_join (thread[i]);

  g_timer_stop (timer);

  elapsed = g_timer_elapsed (timer, NULL);

  g_print ("%ld set_data/get_data pairs per second\n", (glong)(14 * n * rounds / elapsed));

  return 0;
}
