diff options
author | 2015-08-24 16:27:19 -0700 | |
---|---|---|
committer | 2015-08-24 16:27:19 -0700 | |
commit | a0f149e8732c58241795ba6ea198819e359437d2 (patch) | |
tree | bf5ad8f7246a42aa7fd5484e6a73d3e5124866c2 /src/core/support/time_posix.c | |
parent | 0ea28f1ca565e65d7295249ce86bf73647af0929 (diff) |
Move core/profiling/timers_preciseclock.h to core/support/ such that we
have a gpr public function which returns cycle clock.
Diffstat (limited to 'src/core/support/time_posix.c')
-rw-r--r-- | src/core/support/time_posix.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/core/support/time_posix.c b/src/core/support/time_posix.c index 841485c4b4..a274400243 100644 --- a/src/core/support/time_posix.c +++ b/src/core/support/time_posix.c @@ -32,6 +32,7 @@ */ #include <grpc/support/port_platform.h> +#include <src/core/support/time_precise.h> #ifdef GPR_POSIX_TIME @@ -66,8 +67,14 @@ void gpr_time_init(void) {} gpr_timespec gpr_now(gpr_clock_type clock) { struct timespec now; GPR_ASSERT(clock != GPR_TIMESPAN); - clock_gettime(clockid_for_gpr_clock[clock], &now); - return gpr_from_timespec(now, clock); + if (clock == GPR_CLOCK_PRECISE) { + gpr_timespec ret; + gpr_precise_clock_now(&ret); + return ret; + } else { + clock_gettime(clockid_for_gpr_clock[clock], &now); + return gpr_from_timespec(now, clock); + } } #else /* For some reason Apple's OSes haven't implemented clock_gettime. */ @@ -104,6 +111,9 @@ gpr_timespec gpr_now(gpr_clock_type clock) { now.tv_sec = now_dbl * 1e-9; now.tv_nsec = now_dbl - now.tv_sec * 1e9; break; + case GPR_CLOCK_PRECISE: + gpr_precise_clock_now(&now); + break; case GPR_TIMESPAN: abort(); } |