CMM2 vs. PicoMite 2 Mio For-Next-Benchmark

Author Message

Senior Member

Joined: 07/12/2020
Location: Germany
Posts: 182
Posted: 06:15pm 26 Sep 2022      

Using the same code on the PicoMiteVGA (simply by using the same sd-card) I get improved values:

By comparing the old benchmark code to the current code there is one major difference: In the new faster code I did declare the control variable as integer before use within the construct.

Result: Declaring control variables before use results in huge speed-up!


CONST Maxloop = 10000000    
DIM i AS INTEGER = 0        ' gives huge speed-up

FOR i = 1 to Maxloop


NEXT                        ' do not write i after NEXT

It seem to be very important not to write down the control variable after the next-statement.

Writing: for i = 1 to Maxloop : next  

is much faster than

writing: for i = 1 to Maxloop : next i

Doing real measurements on the cmm2 within the loop:

' bench.bas - how fast can you measure

const maxmeasure = 500000 ' number of measurements
dim mess(maxmeasure) as integer
dim i as integer = 0
setpin 33,din ' digital input on pin 33

print "Start... ";
t1 = timer

for i = 1 to maxmeasure: mess(i) = pin(33):next


print diff;" ms for ";maxmeasure;" measurements"
print (maxmeasure/diff)*1000;" measurements per second"


save image "camac.bmp"

Edited 2022-09-27 06:46 by andreas