aboutsummaryrefslogtreecommitdiffstats
path: root/test/monniaux/clock.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/monniaux/clock.c')
-rw-r--r--test/monniaux/clock.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/monniaux/clock.c b/test/monniaux/clock.c
new file mode 100644
index 00000000..4ec679f6
--- /dev/null
+++ b/test/monniaux/clock.c
@@ -0,0 +1,32 @@
+#include "cycles.h"
+#include <stdio.h>
+
+static cycle_t total_clock, last_start;
+
+void clock_prepare(void) {
+ cycle_count_config();
+}
+
+void clock_start(void) {
+ last_start = get_cycle();
+}
+
+void clock_stop(void) {
+ total_clock += get_cycle() - last_start;
+}
+
+cycle_t get_total_clock(void) {
+ return total_clock;
+}
+
+cycle_t get_current_cycle(void) {
+ return get_cycle();
+}
+
+void print_total_clock(void) {
+ printf("time cycles: %" PRcycle "\n", total_clock);
+}
+
+void printerr_total_clock(void) {
+ fprintf(stderr, "time cycles: %" PRcycle "\n", total_clock);
+}