Microsoft KB Archive/40190

From BetaArchive Wiki
Knowledge Base


Same Access Speed for Static, Dynamic Arrays If Debug Is On

Article ID: 40190

Article Last Modified on 11/21/2006



APPLIES TO

  • Microsoft QuickBasic 4.0, when used with:
    • Microsoft MS-DOS 6.22 Standard Edition
  • Microsoft QuickBASIC 4.0b, when used with:
    • Microsoft MS-DOS 6.22 Standard Edition
  • Microsoft QuickBasic 4.5 for MS-DOS, when used with:
    • Microsoft MS-DOS 6.22 Standard Edition
  • Microsoft BASIC Compiler 6.0
  • Microsoft BASIC Compiler 6.0b
  • Microsoft BASIC Professional Development System 7.0



This article was previously published under Q40190

SUMMARY

The code shown below demonstrates that the access time for an array is not dependent upon whether the /AH option is used. Furthermore, a static array requires the same amount of access time as a dynamic array when executed from within QB.EXE or when compiled with the debug (BC /d) option. Static-array access is faster than dynamic-array access when compiled without the debug (BC /d) compiler switch.

This information applies to QuickBasic Versions 4.00, 4.00b, and 4.50, Microsoft Basic Compiler Versions 6.00 and 6.00b for MS-DOS and MS OS/2, and Microsoft Basic PDS Version 7.00 for MS-DOS and OS/2.

MORE INFORMATION

The following times were required for the sample program below when executed under QuickBasic Version 4.50 using the indicated options on an AT compatible running at 10 megahertz with a 6-megahertz 80287 chip:

   Array Type       QB.EXE      BC.EXE /d      BC.EXE No Debug
   ----------       ------      ---------      ---------------
                    With an 80287 coprocessor:

   Huge             23.22       38.05           30.02
   Static           23.17       38.10           17.96
   Dynamic          23.24       38.07           30.32
 

                    Without an 80287 coprocessor:

   Huge             88.65       105.39          97.5
   Static           88.64       105.40          82.6
   Dynamic          88.64       105.45          97.49
                

Earlier versions do not allow huge (larger than 64K) arrays.

The following is sample code:

' $DYNAMIC
DIM ar0(20000)

' $STATIC
DIM ar1(2000)
' $DYNAMIC
DIM ar2(2000)

s# = TIMER
FOR j = 1 TO 100000
   ar0(1) = ar0(1) + ar0(0)
NEXT
PRINT TIMER - s#; " seconds elapsed  FOR HUGE"

s# = TIMER
FOR j = 1 TO 100000
   ar1(1) = ar1(1) + ar1(0)
NEXT
PRINT TIMER - s#; " seconds elapsed FOR STATIC"

s# = TIMER
FOR j = 1 TO 100000
   ar2(1) = ar2(1) + ar2(0)
NEXT
PRINT TIMER - s#; " seconds elapsed FOR DYNAMIC"
                


Additional query words: QuickBas BasicCom

Keywords: KB40190