COBOL – PERFORMANCE IMPROVEMENT
All the options provided below when applied to a COBOL program will improve its performance.
INITIALIZE statement when converted to Machine code after the compile, it would create move statements for each individual field in the GROUP variable separately. Instead, we can make use of a single MOVE statement.
Also in your program, if you had to perform INITIALIZE to a group of variables multiple times, it is advisable to have a separate section of the GROUP variable in the WORKING-STORAGE section with all of the INDIVIDUAL fields INITIALIZED (using VALUES)
and MOVE this GROUP variable to the actual GROUP variable whenever required.
- During Arithmetic Operations (with some limitations), COMP fields provide more performance compared to COMP-3 which indeed provide more performance compared to DISPLAY variables.
- Index represent displacement value of the table entry from the beginning of the table while subscripts represent the occurrence number of an element. The value of an index has the element size factored into it, whereas the value of a subscript must be multiplied by the element size when the subscript is used.
- If SSRANGE is in effect at compile time, range-checking code is generated. This would degrade performance. Also You can inhibit range checking by specifying the CHECK(OFF) runtime option. Doing so leaves range-checking code dormant in the object code. Optionally, the range-checking code can be used to aid in resolving unexpected errors without recompilation.