I have a question about the speed of operations with VIRTUAL arrays.
The following test code, using static arrays, executed on my system in less
than 0.05 seconds:
DIM a?(32000), b?(32000)
CLS
t! = TIMER
FOR j% = 1 TO 10
FOR i% = 0 TO 32000
IF a?(i%)<>b?(i%) THEN x = 0
NEXT i%
NEXT j%
PRINT USING "##.####"; TIMER-t!
The following code, which differs from the above only in the statement "VIRTUAL",
took 13.5 seconds to execute, this is 270 times slower:
DIM VIRTUAL a?(32000), b?(32000)
CLS
t! = TIMER
FOR j% = 1 TO 10
FOR i% = 0 TO 32000
IF a?(i%)<>b?(i%) THEN x = 0
NEXT i%
NEXT j%
PRINT USING "##.####"; TIMER-t!
This last code, which performs the same operation reading data from disk,
took 5.2 seconds:
OPEN "TEST1" FOR BINARY AS #1
OPEN "TEST2" FOR BINARY AS #2
CLS
t! = TIMER
FOR j% = 1 TO 10
FOR i% = 0 TO 32000
GET #1, ,a?
GET #2, ,b?
IF a?<>b? THEN x = 0
NEXT i%
NEXT j%
PRINT USING "##.####"; TIMER-t!
CLOSE
So this is the question: I understand that comparisons between two different
VIRTUAL arrayas require multiple steps of memory remapping. But I never
imagined that these additional steps would result in a factor of 270 compared
with static arrays, and even slower than access to the hard disk! Is there not
a way to make access to VIRTUAL arrays faster?
Hans Ruegg
The following test code, using static arrays, executed on my system in less
than 0.05 seconds:
DIM a?(32000), b?(32000)
CLS
t! = TIMER
FOR j% = 1 TO 10
FOR i% = 0 TO 32000
IF a?(i%)<>b?(i%) THEN x = 0
NEXT i%
NEXT j%
PRINT USING "##.####"; TIMER-t!
The following code, which differs from the above only in the statement "VIRTUAL",
took 13.5 seconds to execute, this is 270 times slower:
DIM VIRTUAL a?(32000), b?(32000)
CLS
t! = TIMER
FOR j% = 1 TO 10
FOR i% = 0 TO 32000
IF a?(i%)<>b?(i%) THEN x = 0
NEXT i%
NEXT j%
PRINT USING "##.####"; TIMER-t!
This last code, which performs the same operation reading data from disk,
took 5.2 seconds:
OPEN "TEST1" FOR BINARY AS #1
OPEN "TEST2" FOR BINARY AS #2
CLS
t! = TIMER
FOR j% = 1 TO 10
FOR i% = 0 TO 32000
GET #1, ,a?
GET #2, ,b?
IF a?<>b? THEN x = 0
NEXT i%
NEXT j%
PRINT USING "##.####"; TIMER-t!
CLOSE
So this is the question: I understand that comparisons between two different
VIRTUAL arrayas require multiple steps of memory remapping. But I never
imagined that these additional steps would result in a factor of 270 compared
with static arrays, and even slower than access to the hard disk! Is there not
a way to make access to VIRTUAL arrays faster?
Hans Ruegg
Comment