![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
Hi all, Having used other languages heavily in conjunction with mvbasic for six years now, I often feel serious limitations inherent in pick basic. While I am running a process I want to build up a variable *unknown* number of two dimensional STATIC arrays. I need the arrays to be STATIC for performance because they are quite large (often about 1000x50) and the process is furiously building them up from scratch. mvbasic only allows you to acquire memory for storage at the point of dimensioning static arrays or by building strings. Object orientated programs are quite happy for you to create a kind of floating array that can be stored within. A lot of people think OO is a design process. Well its much more than that. In this case its about the freedom for variables to contain "things", in this case arrays. |
#2
| |||
| |||
|
|
Luke Webber wrote: Even in MV BASIC, you could simulate them throught the use of one big array, allocated in chunks, with links at either end of those chunks, rather like the hashed storage model. Ugly, but possible. The need to preallocate the "one big array" up front is the main problem. I believe that in some MVBASICS you can enlarge an array without losing the original data. This counts a kind of poor mans dynamic memory allocation but is an abomination compared to the easy and allocation and deallocation of memory resources under virtually any other language. Cheers, Steve |
#3
| |||
| |||
|
|
Luke Webber wrote: Even in MV BASIC, you could simulate them throught the use of one big array, allocated in chunks, with links at either end of those chunks, rather like the hashed storage model. Ugly, but possible. The need to preallocate the "one big array" up front is the main problem. I believe that in some MVBASICS you can enlarge an array without losing the original data. This counts a kind of poor mans dynamic memory allocation but is an abomination compared to the easy and allocation and deallocation of memory resources under virtually any other language. Cheers, Steve |
#4
| |||
| |||
|
|
Luke Webber wrote: Even in MV BASIC, you could simulate them throught the use of one big array, allocated in chunks, with links at either end of those chunks, rather like the hashed storage model. Ugly, but possible. The need to preallocate the "one big array" up front is the main problem. I believe that in some MVBASICS you can enlarge an array without losing the original data. This counts a kind of poor mans dynamic memory allocation but is an abomination compared to the easy and allocation and deallocation of memory resources under virtually any other language. Cheers, Steve |
#5
| |||
| |||
|
|
Steve: It's not often I run into a problem where I need floating sized Dimensioned arrays. Kind of like a solution looking for a problem. :-) Whenever I do I normally just use the dbms. However, I normally use dynamic arrays for up to about 1-2Mb of data, which meets your (1000x50) requirement, which is very small. Bill "SteveB" <steve.bush (AT) neosys (DOT) com> wrote in message news:1151712075.448469.203240 (AT) b68g2000cwa (DOT) googlegroups.com... Luke Webber wrote: Even in MV BASIC, you could simulate them throught the use of one big array, allocated in chunks, with links at either end of those chunks, rather like the hashed storage model. Ugly, but possible. The need to preallocate the "one big array" up front is the main problem. I believe that in some MVBASICS you can enlarge an array without losing the original data. This counts a kind of poor mans dynamic memory allocation but is an abomination compared to the easy and allocation and deallocation of memory resources under virtually any other language. Cheers, Steve |
#6
| |||
| |||
|
|
Bill H wrote: Whenever I do I normally just use the dbms. However, I normally use dynamic arrays for up to about 1-2Mb of data, which meets your (1000x50) requirement, which is very small. Hmm I thought I better get back to basics and do a real test why I cannot use dynamic arrays. According to the tests below, for the case being discussed, it takes around 160 SECONDS to use a dynamic array versus 70 MILLISECONDS to use a DIMENSIONED array in the following reasonable test. Dimensioned arrays in this simple case are more than 2000 times faster. I think this is very strong evidence that dynamic arrays are totally unsuitable as a memory allocation method for very small 1-2Mb arrays. Since dynamic arrays are no use for high performance structures one needs dimensioned arrays and this is my point that due to the lack of OO data structures in the typical MVBASIC they are of limited use. DIMENSIONED ARRAY TEST ------------------------------------ YY='ABCDEFGHIJK' NI=1000 NJ=50 DIM ZZ(NI,NJ) STARTTIME=SYSTEM(1020) FOR II=1 TO NI FOR JJ=1 TO NJ ZZ(RND(NI)+1,RND(NJ)+1)=YY NEXT JJ NEXT II STOPTIME=SYSTEM(1020) PRINT (STOPTIME-STARTTIME) 'MD00':'ms' Takes around 70 MILLISECONDS DYNAMIC ARRAY ---------------------- YY='ABCDEFGHIJK' NI=1000 NJ=50 DIM ZZ(NI,NJ) STARTTIME=SYSTEM(1020) FOR II=1 TO NI FOR JJ=1 TO NJ ZZ(RND(NI)+1,RND(NJ)+1)=YY NEXT JJ NEXT II STOPTIME=SYSTEM(1020) PRINT (STOPTIME-STARTTIME) 'MD00':'ms' Takes around 160 SECONDS (XP Professional SP2 Intel T2400 1.83Ghz using OpenQM under Cygwin and QM for PC from Ladybridge) |
#7
| |||
| |||
|
|
Steve, Your code samples appear to be identical except for the word Dynamic or Dimensioned at the top? How is one thereby Dynamic and the other Dimensioned? Did you mis-copy the code? |
|
"SteveB" <steve.bush (AT) neosys (DOT) com> wrote in message news:1151757003.132100.140560 (AT) v61g2000cwv (DOT) googlegroups.com... Bill H wrote: Whenever I do I normally just use the dbms. However, I normally use dynamic arrays for up to about 1-2Mb of data, which meets your (1000x50) requirement, which is very small. Hmm I thought I better get back to basics and do a real test why I cannot use dynamic arrays. According to the tests below, for the case being discussed, it takes around 160 SECONDS to use a dynamic array versus 70 MILLISECONDS to use a DIMENSIONED array in the following reasonable test. Dimensioned arrays in this simple case are more than 2000 times faster. I think this is very strong evidence that dynamic arrays are totally unsuitable as a memory allocation method for very small 1-2Mb arrays. Since dynamic arrays are no use for high performance structures one needs dimensioned arrays and this is my point that due to the lack of OO data structures in the typical MVBASIC they are of limited use. DIMENSIONED ARRAY TEST ------------------------------------ YY='ABCDEFGHIJK' NI=1000 NJ=50 DIM ZZ(NI,NJ) STARTTIME=SYSTEM(1020) FOR II=1 TO NI FOR JJ=1 TO NJ ZZ(RND(NI)+1,RND(NJ)+1)=YY NEXT JJ NEXT II STOPTIME=SYSTEM(1020) PRINT (STOPTIME-STARTTIME) 'MD00':'ms' Takes around 70 MILLISECONDS DYNAMIC ARRAY ---------------------- YY='ABCDEFGHIJK' NI=1000 NJ=50 DIM ZZ(NI,NJ) STARTTIME=SYSTEM(1020) FOR II=1 TO NI FOR JJ=1 TO NJ ZZ(RND(NI)+1,RND(NJ)+1)=YY NEXT JJ NEXT II STOPTIME=SYSTEM(1020) PRINT (STOPTIME-STARTTIME) 'MD00':'ms' Takes around 160 SECONDS (XP Professional SP2 Intel T2400 1.83Ghz using OpenQM under Cygwin and QM for PC from Ladybridge) |
#8
| |||
| |||
|
|
Homer L. Hazel wrote: Steve, Your code samples appear to be identical except for the word Dynamic or Dimensioned at the top? Umm, yeah. Sorry. Here is the dynamic array version cut and pasted from my test program. YY='ABCDEFGHIJK' NI=1000 NJ=50 ZZ='' STARTTIME=SYSTEM(1020) FOR II=1 TO NI FOR JJ=1 TO NJ ZZ<RND(NI)+1,RND(NJ)+1>=STR('X',RND(10)) NEXT JJ NEXT II STOPTIME=SYSTEM(1020) PRINT (STOPTIME-STARTTIME) 'MD00':'ms' Steve |
#9
| |||
| |||
|
|
Homer L. Hazel wrote: Steve, Your code samples appear to be identical except for the word Dynamic or Dimensioned at the top? SteveB wrote: Umm, yeah. Sorry. Here is the dynamic array version cut and pasted from my test program. YY='ABCDEFGHIJK' NI=1000 NJ=50 ZZ='' STARTTIME=SYSTEM(1020) FOR II=1 TO NI FOR JJ=1 TO NJ ZZ<RND(NI)+1,RND(NJ)+1>=STR('X',RND(10)) NEXT JJ NEXT II STOPTIME=SYSTEM(1020) PRINT (STOPTIME-STARTTIME) 'MD00':'ms' Steve Mike Preece wrote: Well gee. If you compare code that works with 50,000 individually addressable memory locations with one that works with a delimited infinite-length string wouldn't you expect to see a wee difference? I think you might be an idiot. |
#10
| |||
| |||
|
|
Bill H wrote: Whenever I do I normally just use the dbms. However, I normally use dynamic arrays for up to about 1-2Mb of data, which meets your (1000x50) requirement, which is very small. Hmm I thought I better get back to basics and do a real test why I cannot use dynamic arrays. According to the tests below, for the case being discussed, it takes around 160 SECONDS to use a dynamic array versus 70 MILLISECONDS to use a DIMENSIONED array in the following reasonable test. Dimensioned arrays in this simple case are more than 2000 times faster. I think this is very strong evidence that dynamic arrays are totally unsuitable as a memory allocation method for very small 1-2Mb arrays. Since dynamic arrays are no use for high performance structures one needs dimensioned arrays and this is my point that due to the lack of OO data structures in the typical MVBASIC they are of limited use. DIMENSIONED ARRAY TEST ------------------------------------ YY='ABCDEFGHIJK' NI=1000 NJ=50 DIM ZZ(NI,NJ) STARTTIME=SYSTEM(1020) FOR II=1 TO NI FOR JJ=1 TO NJ ZZ(RND(NI)+1,RND(NJ)+1)=YY NEXT JJ NEXT II STOPTIME=SYSTEM(1020) PRINT (STOPTIME-STARTTIME) 'MD00':'ms' Takes around 70 MILLISECONDS DYNAMIC ARRAY ---------------------- YY='ABCDEFGHIJK' NI=1000 NJ=50 DIM ZZ(NI,NJ) STARTTIME=SYSTEM(1020) FOR II=1 TO NI FOR JJ=1 TO NJ ZZ(RND(NI)+1,RND(NJ)+1)=YY NEXT JJ NEXT II STOPTIME=SYSTEM(1020) PRINT (STOPTIME-STARTTIME) 'MD00':'ms' Takes around 160 SECONDS (XP Professional SP2 Intel T2400 1.83Ghz using OpenQM under Cygwin and QM for PC from Ladybridge) |
![]() |
| Thread Tools | |
| Display Modes | |
| |