Author: rjek
Date: Tue Jan 30 15:32:31 2007
New Revision: 3157
URL:
http://svn.semichrome.net?rev=3157&view=rev
Log:
Make time taken that is displayed in status bar use gettimeofday()-based time rather than
clock()-based time
Modified:
trunk/netsurf/content/content.c
trunk/netsurf/content/content.h
trunk/netsurf/utils/utils.c
trunk/netsurf/utils/utils.h
Modified: trunk/netsurf/content/content.c
URL:
http://svn.semichrome.net/trunk/netsurf/content/content.c?rev=3157&r1...
==============================================================================
--- trunk/netsurf/content/content.c (original)
+++ trunk/netsurf/content/content.c Tue Jan 30 15:32:31 2007
@@ -376,7 +376,7 @@
c->refresh = 0;
c->bitmap = 0;
c->fresh = false;
- c->time = clock();
+ c->time = wallclock();
c->size = 0;
c->title = 0;
c->active = 0;
@@ -614,7 +614,7 @@
{
char token[20];
const char *status;
- clock_t time;
+ unsigned int time;
snprintf(token, sizeof token, "HTTP%li", c->http_code);
status = messages_get(token);
@@ -624,13 +624,13 @@
if (c->status == CONTENT_STATUS_TYPE_UNKNOWN ||
c->status == CONTENT_STATUS_LOADING ||
c->status == CONTENT_STATUS_READY)
- time = clock() - c->time;
+ time = wallclock() - c->time;
else
time = c->time;
snprintf(c->status_message, sizeof (c->status_message),
"%s (%.1fs) %s", status,
- (float) time / CLOCKS_PER_SEC, c->sub_status);
+ (float) time / 100, c->sub_status);
/* LOG(("%s", c->status_message)); */
}
@@ -752,7 +752,7 @@
union content_msg_data msg_data;
c->status = CONTENT_STATUS_DONE;
- c->time = clock() - c->time;
+ c->time = wallclock() - c->time;
content_update_status(c);
content_broadcast(c, CONTENT_MSG_DONE, msg_data);
}
Modified: trunk/netsurf/content/content.h
URL:
http://svn.semichrome.net/trunk/netsurf/content/content.h?rev=3157&r1...
==============================================================================
--- trunk/netsurf/content/content.h (original)
+++ trunk/netsurf/content/content.h Tue Jan 30 15:32:31 2007
@@ -16,7 +16,6 @@
#define _NETSURF_DESKTOP_CONTENT_H_
#include <stdint.h>
-#include <time.h>
#include "netsurf/utils/config.h"
#include "netsurf/content/content_type.h"
#include "netsurf/css/css.h"
@@ -179,7 +178,7 @@
* shared between users. */
bool fresh;
struct cache_data *cache_data; /**< Cache control data */
- clock_t time; /**< Creation time, if TYPE_UNKNOWN,
+ unsigned int time; /**< Creation time, if TYPE_UNKNOWN,
LOADING or READY,
otherwise total time. */
Modified: trunk/netsurf/utils/utils.c
URL:
http://svn.semichrome.net/trunk/netsurf/utils/utils.c?rev=3157&r1=315...
==============================================================================
--- trunk/netsurf/utils/utils.c (original)
+++ trunk/netsurf/utils/utils.c Tue Jan 30 15:32:31 2007
@@ -236,6 +236,23 @@
return NULL;
}
+/**
+ * Returns a number of centiseconds, that increases in real time, for the
+ * purposes of measuring how long something takes in wall-clock terms. It uses
+ * gettimeofday() for this. Should the call to gettimeofday() fail, it returns
+ * zero.
+ *
+ * \return number of centiseconds that increases monotonically
+ */
+unsigned int wallclock(void)
+{
+ struct timeval tv;
+
+ if (gettimeofday(&tv, NULL) == -1)
+ return 0;
+
+ return ((tv.tv_sec * 100) + (tv.tv_usec / 10000));
+}
#ifdef __FreeBSD__
Modified: trunk/netsurf/utils/utils.h
URL:
http://svn.semichrome.net/trunk/netsurf/utils/utils.h?rev=3157&r1=315...
==============================================================================
--- trunk/netsurf/utils/utils.h (original)
+++ trunk/netsurf/utils/utils.h Tue Jan 30 15:32:31 2007
@@ -56,6 +56,7 @@
char *human_friendly_bytesize(unsigned long bytesize);
const char *rfc1123_date(time_t t);
char *strcasestr(const char *haystack, const char *needle);
+unsigned int wallclock(void);
#ifdef __FreeBSD__
/* FreeBSD lacks strndup */
char *strndup(const char *s, size_t n);