There are several ways to improve compile-time performance. These include both front end and back end compile-time activities.
Table 6 describes different compiler options to make your program run faster, and to make your compiled program smaller. Note that sometimes you have to decide which is more important to you, program size or program speed. In some cases optimizing for one aspect means the other suffers.
Optimization is the process through which the system looks for processing shortcuts that reduce the amount of system resources necessary to produce output. Processing shortcuts are translated into machine code, allowing the procedures in a module to run more efficiently. A highly optimized program or service program should run faster than it would without optimization.
To control the level of optimization, use the OPTIMIZE option on the Create Module and Create Bound Program commands. Changing the desired optimization level requires recompiling your source code. Changing the optimization of a module can also be accomplished through a Change Module (CHGMOD) command.
You should be aware of the following limitations when working with optimized code:
To circumvent this restriction while debugging, you can lower the optimization level of a module to display fields accurately as you debug a program, and then raise the level again afterwards, to improve the program efficiency as you get the program ready for production.
Use the guidelines in Table 6, except where they are contradicted.
Intrinsic functions may improve performance, but they increase the size of
your module.
Table 6. Compiler Options for Performance
Option | Optimize for Speed | Optimize for Size |
---|---|---|
OPTIMIZE 10 //Default value OPTIMIZE 20 OPTIMIZE 30 OPTIMIZE 40Turns on optimization. | Yes | Yes |
INLINE(*OFF)Turns off inlining. May reduce module size, especially if the inlined functions consist of small pieces of code. | No | Yes |
INLINE(*ON)Turns on inlining. Saves many function calls when a function is called in a few places but executed many times. | Yes | No |
DBGVIEW(*NONE)Does not generate debug information, which would increase module size. | No | Yes |
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.