From 97e789c90b5ab45ffa3237dd2bd5da6158375f7a Mon Sep 17 00:00:00 2001 From: netblue30 Date: Tue, 9 May 2017 09:59:00 -0400 Subject: measure start time --- src/include/common.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/include') diff --git a/src/include/common.h b/src/include/common.h index fc4059334..59b7f6213 100644 --- a/src/include/common.h +++ b/src/include/common.h @@ -109,6 +109,17 @@ static inline int mac_not_zero(const unsigned char mac[6]) { return 0; } +// rtdsc timestamp on x86-64/amd64 processors +static inline unsigned long long getticks(void) { +#if defined(__x86_64__) + unsigned a, d; + asm volatile("rdtsc" : "=a" (a), "=d" (d)); + return ((unsigned long long)a) | (((unsigned long long)d) << 32); +#else + return 0; // not implemented +#endif +} + int join_namespace(pid_t pid, char *type); int name2pid(const char *name, pid_t *pid); char *pid_proc_comm(const pid_t pid); -- cgit v1.2.3-54-g00ecf