Add ustime() from unstable into utils.c

This commit is contained in:
antirez 2011-06-08 23:13:47 +02:00
parent 567d575dbe
commit 32463852be
2 changed files with 12 additions and 0 deletions

View File

@ -327,6 +327,17 @@ int d2string(char *buf, size_t len, double value) {
return len;
}
/* Return the UNIX time in microseconds */
long long ustime(void) {
struct timeval tv;
long long ust;
gettimeofday(&tv, NULL);
ust = ((long long)tv.tv_sec)*1000000;
ust += tv.tv_usec;
return ust;
}
#ifdef UTIL_TEST_MAIN
#include <assert.h>

View File

@ -8,5 +8,6 @@ int ll2string(char *s, size_t len, long long value);
int string2ll(char *s, size_t slen, long long *value);
int string2l(char *s, size_t slen, long *value);
int d2string(char *buf, size_t len, double value);
long long ustime(void);
#endif