From e9bebe253fdecee009414bdce7ccdfba83f980e6 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 13 Dec 2017 15:29:23 +0100 Subject: add simple cache benchmark application --- src/arch/posix/driver/uptime.cc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/arch/posix/driver') diff --git a/src/arch/posix/driver/uptime.cc b/src/arch/posix/driver/uptime.cc index 040b51c..00b1d34 100644 --- a/src/arch/posix/driver/uptime.cc +++ b/src/arch/posix/driver/uptime.cc @@ -1,11 +1,25 @@ #include "driver/uptime.h" #include -uint64_t Uptime::get() +uint64_t Uptime::get_s() { struct timespec ts; clock_gettime(CLOCK_REALTIME, &ts); - return (uint64_t)ts.tv_nsec + (1000000ULL * ((uint64_t)ts.tv_sec % 256)); + return ts.tv_sec; +} + +uint64_t Uptime::get_us() +{ + struct timespec ts; + clock_gettime(CLOCK_REALTIME, &ts); + return ts.tv_nsec / 1000; +} + +uint64_t Uptime::get_cycles() +{ + struct timespec ts; + clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts); + return ts.tv_nsec; } Uptime uptime; -- cgit v1.2.3