The problem here isn't in the copying routines; the problem is with the method used to time the copying...
Lots of SLEEP statements, along with the initialization of the first array, and then printing to the screen... All these things take up time which makes it hard to see what, if any, change the switch from FOR to _MEMCOPY does for your program.
Taking the SLEEP, initialize, and PRINT statements out, and just timing the copy routines themselves, and changing the routines to work off a larger loop limit to highlight the differences, and what we see is the following:
PRINT " COPY Array by FOR" initaz
copyArrayFor
'showarray
oldt1
= TIMER(0.001) - oldt1
PRINT " COPY Array by _MEMCOPY" initaz
CopyArrayMEM
'showarray
oldt2
= TIMER(0.001) - oldt2
PRINT "CopyFor = "; oldt1;
" Copy_MEM = "; oldt2
'--INITIALIZTION
b(i1, i2) = i1
a(i1, i2) = 999
PRINT "SHOWING ARRAYS B A " PRINT b
(i1
, i2
), a
(i1
, i2
)
'copy array a to array b one index at a time:
'FOR...NEXT|
'FOR...NEXT|
b(i1, i2) = a(i1, i2)
'copy array a to array b in memory instantly:
7.7 seconds for the FOR LOOP to copy the arrays.
0.03 seconds for the _MEMCOPY to do its thing.
I think that shows a good comparison of which one might be a
little more faster for our programs.