diff options
author | antirez <antirez@gmail.com> | 2011-06-08 23:13:47 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2011-06-08 23:13:47 +0200 |
commit | 32463852bea9d1ce35093a2673fc582b49373f7a (patch) | |
tree | a32046566451f002a2326ed11226085cd32a192d | |
parent | 567d575dbefbf10d43949b3542d4e05c64632ec5 (diff) | |
download | redis-32463852bea9d1ce35093a2673fc582b49373f7a.tar.gz |
Add ustime() from unstable into utils.c
-rw-r--r-- | src/util.c | 11 | ||||
-rw-r--r-- | src/util.h | 1 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c index f5a23af2a..e34b3a004 100644 --- a/src/util.c +++ b/src/util.c @@ -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> diff --git a/src/util.h b/src/util.h index b897a89e7..339246e95 100644 --- a/src/util.h +++ b/src/util.h @@ -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 |