Permalink
Browse files

ustime() backported from unstable, used by slow log

  • Loading branch information...
1 parent ad6347b commit 33d2761bc05710b4dd6d036e04ca1b3c9d4b2a39 @antirez committed Jul 1, 2011
Showing with 13 additions and 0 deletions.
  1. +1 −0 src/redis.h
  2. +12 −0 src/util.c
View
1 src/redis.h
@@ -869,6 +869,7 @@ int ll2string(char *s, size_t len, long long value);
int isStringRepresentableAsLong(sds s, long *longval);
int isStringRepresentableAsLongLong(sds s, long long *longval);
int isObjectRepresentableAsLongLong(robj *o, long long *llongval);
+long long ustime(void);
/* Configuration */
void loadServerConfig(char *filename);
View
12 src/util.c
@@ -1,6 +1,7 @@
#include "redis.h"
#include <ctype.h>
#include <limits.h>
+#include <sys/time.h>
/* Glob-style pattern matching. */
int stringmatchlen(const char *pattern, int patternLen,
@@ -241,3 +242,14 @@ int isObjectRepresentableAsLongLong(robj *o, long long *llongval) {
return isStringRepresentableAsLongLong(o->ptr,llongval);
}
}
+
+/* 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;
+}

0 comments on commit 33d2761

Please sign in to comment.