summaryrefslogtreecommitdiff
path: root/src/app/bench/main.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/bench/main.cc')
-rw-r--r--src/app/bench/main.cc68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/app/bench/main.cc b/src/app/bench/main.cc
new file mode 100644
index 0000000..cdbc00f
--- /dev/null
+++ b/src/app/bench/main.cc
@@ -0,0 +1,68 @@
+#include "arch.h"
+#include "driver/gpio.h"
+#include "driver/stdout.h"
+#include "driver/uptime.h"
+
+#ifndef TIMER_CYCLES
+#error makeflag timer_cycles=1 required
+#endif
+
+
+/*
+ * For ESP8266: Flash reads must be 4-Byte-aligned -> uint32_t array
+ */
+
+__attribute__ ((section(".text"))) uint32_t arr[4096];
+//uint32_t arr[1024];
+uint16_t frob;
+
+inline uint16_t bench_read(uint32_t *arr)
+{
+ uint16_t ts_pre, ts_post;
+ ts_pre = uptime.get_cycles();
+ frob += *arr;
+ ts_post = uptime.get_cycles();
+ return ts_post - ts_pre;
+}
+
+int main(void)
+{
+ arch.setup();
+ gpio.setup();
+ kout.setup();
+
+ uint16_t ts1 = uptime.get_cycles();
+ uint16_t ts2 = uptime.get_cycles();
+ uint16_t ts3 = uptime.get_cycles();
+ uint16_t ts4 = uptime.get_cycles();
+ uint16_t i;
+
+ //for (i = 0; i < 1024; i++) {
+ // arr[i] = 1;
+ //}
+
+ gpio.led_on(0);
+ kout << "Hello, World!" << endl;
+ kout << "Test, World!" << endl;
+ kout << dec << ts1 << endl;
+ kout << dec << ts2 << endl;
+ kout << dec << ts3 << endl;
+ kout << dec << ts4 << endl;
+
+ for (int i = 0; i < sizeof(arr) / sizeof(uint32_t); i++) {
+ kout << i << ": " << bench_read(&arr[i]) << endl;
+ }
+ for (signed int i = (sizeof(arr) / sizeof(uint32_t)) - 1; i >= 0; i--) {
+ kout << i << ": " << bench_read(&arr[i]) << endl;
+ }
+ kout << frob << endl;
+
+ arch.idle_loop();
+
+ //uart_setup();
+ //uart_puts("\n" COL_YELLOW "dOS" COL_GREEN " > " COL_RESET);
+
+ //arch_idle_loop();
+
+ return 0;
+}