From 37daa5ddde96e4b95f636db7b71e80ddaf415ff6 Mon Sep 17 00:00:00 2001 From: IanSB Date: Thu, 4 Nov 2021 01:56:34 +0000 Subject: [PATCH] Add GPIO benchmark --- src/rgb_to_fb.S | 31 +++++++++++++++++++++++++++++-- src/rgb_to_hdmi.c | 4 +++- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/rgb_to_fb.S b/src/rgb_to_fb.S index 51024528..acca7fc5 100644 --- a/src/rgb_to_fb.S +++ b/src/rgb_to_fb.S @@ -2136,11 +2136,19 @@ delay_loop: benchmarkRAM: push {r1-r12, lr} // RAM address in r0 returns with time in r0 + cmp r0, #0 + beq gpio_bench + mov r1, r0 + add r2, r1, #4000 +preload_benchloop2: + ldr r6, [r1], #4 + cmp r1, r2 + blt preload_benchloop2 READ_CYCLE_COUNTER r4 - mov r3, #1024 + mov r3, #1000 benchloop: mov r1, r0 - add r2, r1, #1024 + add r2, r1, #4000 benchloop2: ldr r6, [r1], #4 cmp r1, r2 @@ -2151,6 +2159,25 @@ benchloop2: subs r0, r5, r4 rsbmi r0, r0, #1 pop {r1-r12, pc} + +gpio_bench: + ldr r4, =GPLEV0 + READ_CYCLE_COUNTER r6 + mov r3, #1000 +gbenchloop: + mov r1, #0 +gbenchloop2: + ldr r8, [r4] + add r1, r1, #1 + cmp r1, #1000 + blt gbenchloop2 + subs r3, r3, #1 + bne gbenchloop + READ_CYCLE_COUNTER r7 + subs r0, r7, r6 + rsbmi r0, r0, #1 + pop {r1-r12, pc} + .ltorg diff --git a/src/rgb_to_hdmi.c b/src/rgb_to_hdmi.c index 83fbf890..5d00c463 100644 --- a/src/rgb_to_hdmi.c +++ b/src/rgb_to_hdmi.c @@ -3089,7 +3089,9 @@ void rgb_to_hdmi_main() { init_framebuffer(capinfo); log_debug("Done setting up frame buffer"); //log_info("Peripheral base = %08X", PERIPHERAL_BASE); - log_info("RAM benchmark: Main memory = %d ns, Screen memory = %d ns", (int) ((double) benchmarkRAM(dummyscreen) * 1000 / cpuspeed), (int) ((double) benchmarkRAM((int) capinfo->fb) * 1000 / cpuspeed)); + + log_info("GPIO read = %d ns, Cached read = %d ns, Screen read = %d ns", (int)((double) benchmarkRAM(0) * 1000 / cpuspeed / 1000000 + 0.5), + (int)((double) benchmarkRAM(0x2000000) * 1000 / cpuspeed / 1000000 + 0.5), (int)((double) benchmarkRAM((int) capinfo->fb) * 1000 / cpuspeed / 1000000 + 0.5)); geometry_get_fb_params(capinfo); capinfo->ncapture = ncapture;