Add simple timer for resolver test program
authorMarcel Holtmann <marcel@holtmann.org>
Wed, 28 Jul 2010 17:34:12 +0000 (10:34 -0700)
committerMarcel Holtmann <marcel@holtmann.org>
Wed, 28 Jul 2010 17:34:12 +0000 (10:34 -0700)
tools/resolv-test.c

index 637c9e3..6112406 100644 (file)
@@ -30,7 +30,9 @@
 
 #include <gresolv/gresolv.h>
 
-static GMainLoop *main_loop = NULL;
+static GTimer *timer;
+
+static GMainLoop *main_loop;
 
 static void resolv_debug(const char *str, void *data)
 {
@@ -45,8 +47,13 @@ static void sig_term(int sig)
 static void resolv_result(GResolvResultStatus status,
                                        char **results, gpointer user_data)
 {
+       gdouble elapsed;
        int i;
 
+       elapsed = g_timer_elapsed(timer, NULL);
+
+       g_print("elapse: %f seconds\n", elapsed);
+
        g_print("status: %d\n", status);
 
        if (results != NULL) {
@@ -111,6 +118,8 @@ int main(int argc, char *argv[])
        } else
                g_resolv_add_nameserver(resolv, "127.0.0.1", 53, 0);
 
+       timer = g_timer_new();
+
        g_resolv_lookup_hostname(resolv, argv[1], resolv_result, NULL);
 
        memset(&sa, 0, sizeof(sa));
@@ -120,6 +129,8 @@ int main(int argc, char *argv[])
 
        g_main_loop_run(main_loop);
 
+       g_timer_destroy(timer);
+
        g_resolv_unref(resolv);
 
        g_main_loop_unref(main_loop);