#include <glib-object.h>
#include <stdio.h>
#include <gst/gstminiobject.h>

#define NUM_OBJECTS 10000000

static void
miniclass_instance_init (void *self)
{
}

static void
miniclass_class_init (void *klass)
{
}

static GType
miniclass_get_type (void)
{
  static GType miniclass_type_id = 0;

  if (miniclass_type_id == 0)
    {
      static const GTypeInfo g_define_type_info =
        {
          sizeof (GstMiniObjectClass),
          (GBaseInitFunc) NULL,
          (GBaseFinalizeFunc) NULL,
          (GClassInitFunc) miniclass_class_init,
          (GClassFinalizeFunc) NULL,
          NULL,
          sizeof (GstMiniObject),
          0,
          (GInstanceInitFunc) miniclass_instance_init
        };

      miniclass_type_id
        = g_type_register_static (GST_TYPE_MINI_OBJECT, "MiniClass",
                                  &g_define_type_info, 0);
    }

  return miniclass_type_id;
}

int
main (int argc, char **argv)
{
  int i;
  GTimer *timer;
  double elapsed;

  g_type_init ();

  timer = g_timer_new ();

  g_timer_start (timer);

  for (i = 0; i < NUM_OBJECTS; i++)
    {
      GObject *obj = g_object_new (G_TYPE_OBJECT, NULL);

      g_object_unref (obj);
    }

  elapsed = g_timer_elapsed (timer, NULL);

  printf ("%i GObjects in %f seconds = %f objects per second\n",
          NUM_OBJECTS, elapsed, NUM_OBJECTS / elapsed);

  g_timer_start (timer);

  for (i = 0; i < NUM_OBJECTS; i++)
    {
      GstMiniObject *obj = gst_mini_object_new (miniclass_get_type ());

      gst_mini_object_unref (obj);
    }

  elapsed = g_timer_elapsed (timer, NULL);

  printf ("%i GstMiniObjects in %f seconds = %f objects per second\n",
          NUM_OBJECTS, elapsed, NUM_OBJECTS / elapsed);

  return 0;
}
