]> err.no Git - varnish/commitdiff
gettimeofday() is good enough for varnishstat.
authordes <des@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Thu, 19 Jul 2007 10:58:31 +0000 (10:58 +0000)
committerdes <des@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Thu, 19 Jul 2007 10:58:31 +0000 (10:58 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1715 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishstat/varnishstat.c

index 622eb7d65c8611b4ae8459c5428029483260802e..06b895c87aa4e2d6fa140675f40b4ddf43885de3 100644 (file)
@@ -32,6 +32,8 @@
  * Log tailer for Varnish
  */
 
+#include <sys/time.h>
+
 #include <curses.h>
 #include <errno.h>
 #include <limits.h>
 #include <time.h>
 #include <unistd.h>
 
-#ifndef HAVE_CLOCK_GETTIME
-#include "compat/clock_gettime.h"
-#endif
-
 #include "libvarnish.h"
 #include "shmlog.h"
 #include "varnishapi.h"
@@ -64,7 +62,7 @@ do_curses(struct varnish_stats *VSL_stats, int delay)
 {
        struct varnish_stats copy;
        intmax_t ju;
-       struct timespec ts;
+       struct timeval tv;
        double tt, lt, hit, miss, ratio, up;
        double a1, a2, a3;
        unsigned n1, n2, n3;
@@ -86,11 +84,11 @@ do_curses(struct varnish_stats *VSL_stats, int delay)
 
        lt = 0;
        while (1) {
-               clock_gettime(CLOCK_REALTIME, &ts);
-               tt = ts.tv_nsec * 1e-9 + ts.tv_sec;
+               gettimeofday(&tv, NULL);
+               tt = tv.tv_usec * 1e-6 + tv.tv_sec;
                lt = tt - lt;
 
-               rt = ts.tv_sec - VSL_stats->start_time;
+               rt = tv.tv_sec - VSL_stats->start_time;
                up = rt;
 
                mvprintw(0, 0, "%*s", COLS - 1, VSL_Name());