CMM2 vs. PicoMite 2 Mio For-Next-Benchmark


Author Message
andreas

Senior Member

Joined: 07/12/2020
Location: Germany
Posts: 188
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 for..next construct.

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

Example:

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

FOR i = 1 to Maxloop

 'Do_something

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 for..next loop:



' bench.bas - how fast can you measure

const maxmeasure = 500000 ' number of measurements
cls
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

diff=timer-t1

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

memory

save image "camac.bmp"



-andreas
Edited 2022-09-27 06:46 by andreas