#include <stdio.h>
#include <stdlib.h>
#include "gio/gio.h"

const char *name;

void
get_dbus_id (GDBusConnection *bus)
{
  GVariant *ret;
  GError *error = NULL;
  guint result;

  ret = g_dbus_connection_call_sync (bus, "org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "GetConnectionUnixProcessID", g_variant_new ("(s)", name), NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
  g_variant_get (ret, "(u)", &result);
}

main(int argc, const char *argv[])
{
  GDBusConnection *bus;
  int i;
  GError *error = NULL;

  g_type_init ();
  bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
  if (!bus)
  {
    fprintf(stderr, "Couldn't find the bus stop\n");
    return 1;
  }
  name = g_dbus_connection_get_unique_name (bus);
  for (i = 0; i < 20000; i++)
  {
    get_dbus_id (bus);
  }
}
