Skip to content

Commit

Permalink
Add ustime() from unstable into utils.c
Browse files Browse the repository at this point in the history
  • Loading branch information
antirez committed Jun 8, 2011
1 parent 567d575 commit 3246385
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
1 change: 1 addition & 0 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 3246385

Please sign in to comment.