Skip to content
This repository has been archived by the owner on Dec 5, 2023. It is now read-only.

Commit

Permalink
ustime() added as it is used by scripting.c
Browse files Browse the repository at this point in the history
  • Loading branch information
antirez committed May 11, 2011
1 parent be6e759 commit d59abab
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/redis.h
Expand Up @@ -873,6 +873,7 @@ int isStringRepresentableAsLong(sds s, long *longval);
int isStringRepresentableAsLongLong(sds s, long long *longval);
int isObjectRepresentableAsLongLong(robj *o, long long *llongval);
int string2ll(char *s, size_t slen, long long *value);
long long ustime(void);

/* Configuration */
void loadServerConfig(char *filename);
Expand Down
12 changes: 12 additions & 0 deletions 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,
Expand Down Expand Up @@ -301,3 +302,14 @@ int string2ll(char *s, size_t slen, long long *value) {
}
return 1;
}

/* 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 d59abab

Please sign in to comment.