Mailing List Archive

r1715 - trunk/varnish-cache/bin/varnishstat
Author: des
Date: 2007-07-19 12:58:31 +0200 (Thu, 19 Jul 2007)
New Revision: 1715

Modified:
trunk/varnish-cache/bin/varnishstat/varnishstat.c
Log:
gettimeofday() is good enough for varnishstat.


Modified: trunk/varnish-cache/bin/varnishstat/varnishstat.c
===================================================================
--- trunk/varnish-cache/bin/varnishstat/varnishstat.c 2007-07-17 17:06:12 UTC (rev 1714)
+++ trunk/varnish-cache/bin/varnishstat/varnishstat.c 2007-07-19 10:58:31 UTC (rev 1715)
@@ -32,6 +32,8 @@
* Log tailer for Varnish
*/

+#include <sys/time.h>
+
#include <curses.h>
#include <errno.h>
#include <limits.h>
@@ -42,10 +44,6 @@
#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 @@
{
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 @@

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());