Using indexes to address a table is more efficient than using subscripts since the index already
contains the displacement from the start of the table and does not have to be calculated at run time.
Subscripts, on the other hand, contain an occurrence number that must be converted to a
displacement value at run time before it can be used.
When using subscripts to address a table, use a binary (COMP) signed data item with eight or fewer
digits (for example, using PICTURE S9(8) COMP for the data item). This will allow fullword
arithmetic to be used during the calculations. Additionally, in some cases, using four or fewer digits
for the data item may also offer some added reduction in CPU time since halfword arithmetic can be
used.
Performance considerations for indexes vs subscripts (PIC S9(8)):
● using binary data items (COMP) to address a table is 56% slower than using indexes
● using decimal data items (COMP-3) to address a table is 426% slower than using indexes
● using DISPLAY data items to address a table is 680% slower than using indexes
contains the displacement from the start of the table and does not have to be calculated at run time.
Subscripts, on the other hand, contain an occurrence number that must be converted to a
displacement value at run time before it can be used.
When using subscripts to address a table, use a binary (COMP) signed data item with eight or fewer
digits (for example, using PICTURE S9(8) COMP for the data item). This will allow fullword
arithmetic to be used during the calculations. Additionally, in some cases, using four or fewer digits
for the data item may also offer some added reduction in CPU time since halfword arithmetic can be
used.
Performance considerations for indexes vs subscripts (PIC S9(8)):
● using binary data items (COMP) to address a table is 56% slower than using indexes
● using decimal data items (COMP-3) to address a table is 426% slower than using indexes
● using DISPLAY data items to address a table is 680% slower than using indexes