in file server.c
dirty = server.dirty;
start = ustime();
c->cmd->proc(c);
duration = ustime()-start;
where ustime defined as
/* 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;
}
gettimeofday will be influence by setting of wall clock, such as system admin or NTP. Maybe it is better to use MONOTONIC time to measure time cost of function(such as clock_gettime)?
- ref https://github.com/antirez/redis/issues/5217
- ref https://github.com/antirez/redis/issues/4851
Comment From: 0xtonyxia
There is discussion very long time ago and explained why. #416
Comment From: filipecosta90
Requesting core team to close as this was addressed by #7644.