diff options
author | Rob Kendrick <rjek@netsurf-browser.org> | 2007-01-30 15:32:31 +0000 |
---|---|---|
committer | Rob Kendrick <rjek@netsurf-browser.org> | 2007-01-30 15:32:31 +0000 |
commit | 7c88381a59771a3e0be35800af3496da1171e9a4 (patch) | |
tree | 06ec2e369b3fa856c249d0ea9983105eff489d37 /utils/utils.c | |
parent | f3e6ad3e9093bca4f8e053aa43ddf0631c9d4a18 (diff) | |
download | netsurf-7c88381a59771a3e0be35800af3496da1171e9a4.tar.gz netsurf-7c88381a59771a3e0be35800af3496da1171e9a4.tar.bz2 |
Make time taken that is displayed in status bar use gettimeofday()-based time rather than clock()-based time
svn path=/trunk/netsurf/; revision=3157
Diffstat (limited to 'utils/utils.c')
-rw-r--r-- | utils/utils.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/utils/utils.c b/utils/utils.c index 05f0059ec..b0707b7f2 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -236,6 +236,23 @@ char *strcasestr(const char *haystack, const char *needle) 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__ |