BASIC for the RPi Pico
C vs BASIC Performance on RPi Pico
Been working on a BASIC port and did some comparison between ARMbasic and gcc
Sure there are Coremark numbers published by all chip vendors. But Coremark is copyrighted and takes a little configuring and only in C. Mine are not intended as an expansive benchmark, but as a quick test that can be implemented in a few minutes on nearly any device or language.
Floating point test
dim x as single
x=1000000
while x>1
x=x/1.0001
i=i+1 ' -- count iterations -- about 138K
loop
Integer test
i=1000000
while i
i=i-1
loop
The same benchMark workload run as bare-metal C against the ARMbasic (which is compiled)
on a Raspberry Pi Pico (RP2040, 125 MHz):
| C (ms) | BASIC (ms) | C/BASIC | |
|---|---|---|---|
| Integer | 96 ms | 117 ms | 0.82 |
| Float | 591 ms | 690 ms | 0.86 |
C edges BASIC by ~15–20 % on both loops. The float gap is similar to the integer gap, which means the BASIC float path isn't paying any large overhead beyond what the integer path already pays.
The C source for benchMark lives at CMSIS/benchMark.c — it does
the same two loops the BASIC test does, times each with micros(),
and prints the elapsed microseconds.