There are a range of techniques for maximizing the performance of your COBOL programs. As a general rule, the simpler the operation, the faster it executes and the smaller the compiled code. For the best performance it is often better to use a number of simple operations rather than one complex operation.
These techniques for maximizing performance involve:
- Defining data items appropriately and aligning them to give the best performance.
- Arithmetic statements, for which simple two-operand statements are the most efficient.
- COMPUTE statements, which are for floating-point calculations.
- Decimal point alignment. For operations on non-integer numbers, make the decimal point alignment of the operands match.
- Exponential operations, some of which are optimized. For others, use MULTIPLY and DIVIDE.
- Data item initialization. By default, COBOL initializes all data items in the Working-Storage Section to spaces if no VALUE clause is specified.
- Data manipulation and reference modification, and how to use the MOVE, INITIALIZE, STRING and UNSTRING statements.
- Handling tables. For example, make each subscript a COMP-5 item of the smallest optimum size for the values involved, and use the BOUND directive only when debugging.
- Logical operations, such as AND, OR and XOR. These are, if possible, optimized to produce in-line code.
- PERFORM statements. These are generally very efficient, although you can increase their performance in a number of ways.
- CALL statements. For example, to use these efficiently, call the program using a literal rather than a data-name, limit the number of CALL statements, and so on.
- Passing parameters. For example. avoid making many references to linkage items.
- Sorting files.
- Aligning bit data.