summaryrefslogtreecommitdiff
path: root/src/arch/posix
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2017-12-13 15:29:23 +0100
committerDaniel Friesel <derf@finalrewind.org>2017-12-13 15:29:23 +0100
commite9bebe253fdecee009414bdce7ccdfba83f980e6 (patch)
tree49330d7108869ddfbe8682fb6f20ff79794f57b5 /src/arch/posix
parent22f2335259594569ba4a95544939ef72f3d1bb9d (diff)
add simple cache benchmark application
Diffstat (limited to 'src/arch/posix')
-rw-r--r--src/arch/posix/Makefile.inc6
-rw-r--r--src/arch/posix/driver/uptime.cc18
2 files changed, 21 insertions, 3 deletions
diff --git a/src/arch/posix/Makefile.inc b/src/arch/posix/Makefile.inc
index 7553fd4..03b6f67 100644
--- a/src/arch/posix/Makefile.inc
+++ b/src/arch/posix/Makefile.inc
@@ -19,7 +19,11 @@ build/system.elf: ${OBJECTS}
run: build/system.elf
build/system.elf
+monitor: run
+
+program: run
+
arch_clean:
rm -f ${OBJECTS}
-.PHONY: arch_clean program
+.PHONY: arch_clean monitor program run
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 <time.h>
-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;