Compaq COBOL AAQ2G1FTK User Manual

Page 497

Advertising
background image

Optimizing Your Compaq COBOL Program

15.3 Using COMP Data Items for Speed

SCA and LSE

The Source Code Analyzer (SCA) can help discover program interdependencies
as you contemplate changes. For example, if it is proposed that an item declared
COMP-3 be changed, SCA can quickly and easily find all the references to that
item.

If SCA is used in conjunction with the Language-Sensitive Editor (LSE), LSE can
bring up buffers in your editing session with each of the references.

Oracle CDD/Repository

The Common Data Dictionary can store data definitions and dependency
information, which can then be maintained from one centralized location.

prof, pixie

On Tru64 UNIX, these performance analysis tools can be used to identify
programs (

prof

) or sections of programs (

pixie

) that require large amounts

of CPU time. If 80 percent of the processing time is used by 20 percent of the
COBOL routines, you may benefit from converting only these routines to use
COMP.

15.4 Other Ways to Improve the Performance of Operations on

Numeric Data

In addition to using COMP data items whenever possible for arithmetic
operations in programs, there are other ways to improve performance through the
choice of numeric data types, as discussed in this section.

15.4.1 Mixing Scale Factors and Data Types

Scaling is the process of aligning decimal points for numeric data items. Where
possible, avoid mixing different scale-factors and data types in arithmetic
operations.

In general, type conversions can be minimized by using operands of the same
usage. Scaling operations can be minimized by using compatible scale factors
according to the operation. For example, for add and subtract, all operands
should have the same number of fractional digits; for multiply, the number of
fractional digits in the result should be the same as the sum of the number of
fractional digits in the other two operands.

15.4.2 Limiting Significant Digits

In general, the fewer significant digits in an item, the better the performance
(except as described in Section 15.4.1). For example, for a numeric data item to
contain a number from 1 to 999, declare it as PIC 9(3), not PIC 9(10). This will
also save storage.

15.4.3 Reducing the Compexity of Arithmetic Expressions

When the compiler evaluates an arithmetic expression, it must create
intermediate data items to store the cumulative results of the successive
arithmetic operations in the expression. Such intermediate data items have
PICTUREs large enough to hold the largest and smallest possible intermediate
resulting values for the particular arithmetic operation and the data items upon
which it operates. In general, the more complex the arithmetic expression, the
larger each successive intermediate data item’s PICTURE grows. In particular, if
a divide or exponentiation operation is not the last or only arithmetic operation
in the expression, the corresponding intermediate data item and subsequent

Optimizing Your Compaq COBOL Program 15–7

Advertising