summaryrefslogtreecommitdiff
path: root/utils/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'utils/utils.c')
-rw-r--r--utils/utils.c17
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__