aboutsummaryrefslogtreecommitdiffstats
path: root/test/monniaux/cycles.h
diff options
context:
space:
mode:
Diffstat (limited to 'test/monniaux/cycles.h')
-rw-r--r--test/monniaux/cycles.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/monniaux/cycles.h b/test/monniaux/cycles.h
index 4231a34e..f072e479 100644
--- a/test/monniaux/cycles.h
+++ b/test/monniaux/cycles.h
@@ -1,5 +1,11 @@
+#include <inttypes.h>
typedef unsigned long cycle_t;
+#ifdef MAX_MEASURES
+ cycle_t _last_stop = 0;
+ cycle_t _total_cycles[MAX_MEASURES] = {0};
+#endif
+
#ifdef __K1C__
#include <../../k1-cos/include/hal/cos_registers.h>
@@ -35,3 +41,8 @@ static inline cycle_t get_cycle(void) {
static inline cycle_t get_cycle(void) { return 0; }
#endif
#endif
+
+#ifdef MAX_MEASURES
+ #define TIMESTOP(i) {cycle_t cur = get_cycle(); _total_cycles[i] += cur - _last_stop; _last_stop = cur;}
+ #define TIMEPRINT(n) { for (int i = 0; i <= n; i++) printf("(%d) cycles: %" PRIu64 "\n", i, _total_cycles[i]); }
+#endif