diff options
author | Christian Cunningham <cc@localhost> | 2022-04-05 17:12:06 -0700 |
---|---|---|
committer | Christian Cunningham <cc@localhost> | 2022-04-05 17:12:06 -0700 |
commit | def38067a79a9f193658be58705afa9c091013ff (patch) | |
tree | 2866b300bdf8483795917f9700325f4bb6709b63 /usr/test.c | |
parent | 7928a3c92869cc9e74a4ba6a7298c625303719b2 (diff) |
Cleanup main
Move tests to usr/test.c
Diffstat (limited to 'usr/test.c')
-rw-r--r-- | usr/test.c | 78 |
1 files changed, 78 insertions, 0 deletions
@@ -1,4 +1,5 @@ #include <cpu.h> +#include <cpu/irq.h> #include <graphics/lfb.h> #include <sys/schedule.h> #include <usr/math.h> @@ -192,3 +193,80 @@ void test_super(void) } add_thread(test_results,(void*) 11, 0);idx = 0; } + +void delaytest(void) +{ + static unsigned long count = 0; + static unsigned long long ts[4096*2+20]; + sys0_64(SYS_TIME, &ts[count++]); + if (count == (4096*2+18)) { + unsubscribe_irq(SYS_TIMER_3_IRQ); + static char str[14]; + char* start; + unsigned long mean=0, stdev=0, max=0, min=0xFFFFFFFF; + for (unsigned long i = 0; i < 4096; i++) { + unsigned long elapsed = ts[2*(i+2)+1]-ts[2*(i+2)]; + elapsed *= 1000; + mean += elapsed; + if (elapsed > max) + max = elapsed; + if (elapsed < min) + min = elapsed; + } + mean /= 4096; + for (unsigned long i = 0; i < 4096; i++) { + unsigned long elapsed = ts[2*(i+2)+1]-ts[2*(i+2)]; + elapsed *= 1000; + unsigned long term = (elapsed-mean)*(elapsed-mean)/4096; + stdev += term; + } + stdev = sqrt_rnd(stdev); + start = ulong_to_string(mean, str); + draw_string(0, 10, start); + start = ulong_to_string(stdev, str); + draw_string(0, 11, start); + start = ulong_to_string(min, str); + draw_string(0, 12, start); + start = ulong_to_string(max, str); + draw_string(0, 13, start); + } +} + +void gptest(void) +{ + static unsigned long count = 0; + static unsigned long long ts[4096*2+20]; + sys0_64(SYS_TIME, &ts[count++]); + if (count == (4096*2+18)) { + unsubscribe_irq(GPIO_BANK_1_IRQ); + //unsubscribe_irq(SYS_TIMER_3_IRQ); + static char str[14]; + char* start; + unsigned long mean=0, stdev=0, max=0, min=0xFFFFFFFF; + for (unsigned long i = 0; i < 4096; i++) { + unsigned long elapsed = ts[2*(i+2)+1]-ts[2*(i+2)]; + elapsed *= 1000; + mean += elapsed; + if (elapsed > max) + max = elapsed; + if (elapsed < min) + min = elapsed; + } + mean /= 4096; + for (unsigned long i = 0; i < 4096; i++) { + unsigned long elapsed = ts[2*(i+2)+1]-ts[2*(i+2)]; + elapsed *= 1000; + unsigned long term = (elapsed-mean)*(elapsed-mean)/4096; + stdev += term; + } + stdev = sqrt_rnd(stdev); + start = ulong_to_string(mean, str); + draw_string(0, 10, start); + start = ulong_to_string(stdev, str); + draw_string(0, 11, start); + start = ulong_to_string(min, str); + draw_string(0, 12, start); + start = ulong_to_string(max, str); + draw_string(0, 13, start); + } +}
\ No newline at end of file |