The examples below illustrate when to use the Natural Optimizer Compiler to the best advantage and to give an indication of its power:
This Dokument covers the following topics:
Nothing would be gained by using the Natural Optimizer Compiler for the following program, since it contains a statement that performs database access and an I/O statement (see Statements that are Not Compiled):
DEFINE DATA LOCAL 1 EMPLOYEES VIEW OF EMPLOYEES 2 JOB-TITLE 2 BIRTH 2 NAME END-DEFINE FIND EMPLOYEES WITH JOB-TITLE = 'PROGRAMMER' OR = 'ANALYST' OR = 'PROGRAMMER/ANALYST' OR = 'SYSTEM ANALYST' DISPLAY JOB-TITLE BIRTH NAME END-FIND END
If the following program is compiled with the Natural Optimizer Compiler, you will see a performance improvement of approximately 30 % (that is a 30 % reduction in CPU load). The program performs a statistical analysis of the age of IT-employees. Optimized statements are indicated in boldface.
In this example, the Natural Optimizer Compiler increases the object size by 20.5 %, due to 952 bytes of additional machine code:
Profile Parameter Setting | Size in Buffer Pool | Size of Machine Code Generated by NOC |
---|---|---|
OPT=NODBG |
5768 | 952 |
OPT=OFF |
4784 | 0 |
DEFINE DATA LOCAL 1 EMPLOY VIEW OF EMPLOYEES 2 JOB-TITLE (A25) 2 BIRTH (D) 1 I (I1) INIT <1> 1 CDATE (D) 1 NUMB (N4) 1 SUMM (P7.2) 1 SQUARE (F8) 1 DEVI (F8) 1 DEVIATION (N3.4) 1 MEAN (P2.3) 1 AGEDIS (F8/1:70) 1 AGEMAX (F8) 1 AGEH (P3) 1 AGE (P3) 1 AGEDAYS (P15) 1 LINE (A71/1:20) 1 REDEFINE LINE 2 POINTS (A1/1:20,0:70) END-DEFINE * MOVE *DATX TO CDATE * FIND EMPLOY WITH JOB-TITLE = 'PROGRAMMER' OR = 'ANALYST' OR = 'PROGRAMMER/ANALYST' OR = 'SYSTEM ANALYST' AGEDAYS:= CDATE - BIRTH AGE:=AGEDAYS / 365 ADD 1 TO AGEDIS(AGE) /* DISTRIBUTION ADD 1 TO NUMB ADD AGE TO SUMM COMPUTE SQUARE = SQUARE + AGE * AGE END-FIND * ***************************************************************** * COMPUTE ESTIMATES ***************************************************************** * COMPUTE DEVI = NUMB * SQUARE / (SUMM * SUMM) - 1 COMPUTE DEVIATION = SQRT(DEVI) COMPUTE MEAN = SUMM / NUMB * ***************************************************************** * GRAPHIC DISPLAY ***************************************************************** * FOR I 1 70 IF AGEDIS(I) > AGEMAX MOVE AGEDIS(I) TO AGEMAX END-IF END-FOR FOR I 1 70 COMPUTE AGEDIS(I) = AGEDIS(I) * 20 / AGEMAX END-FOR FOR I 1 70 COMPUTE AGEH = 21 - AGEDIS(I) IF AGEH < 21 MOVE '*' TO POINTS(AGEH:20,I) END-IF END-FOR * ***************************************************************** * COMPLETE GRAPHIC DISPLAY ***************************************************************** * MOVE '!' TO POINTS(*,0) WRITE TITLE LEFT AGEMAX(EM=999) 20X 'DISTRIBUTION OF IT-EMPLOYEES BY AGE' WRITE NOTITLE NOHDR LINE(*) / '0--------10--------20--------30--------40--------50--------60--------' / 'MEAN='
The following program illustrates the difference in CPU usage, depending on the options you select when compiling the program. The table below lists the CPU usage in seconds and percent. The figures provided in the table were determined during a test run in an IBM z/OS environment. They can only serve as general orientation, since absolute values vary depending on the hardware applied.
DEFINE DATA LOCAL 1 #I1 (I4) INIT <1> 1 #I2 (I4) INIT <2> 1 #J1 (I4) INIT <3> 1 #J2 (I4) INIT <4> 1 #F (I4) 1 #ARR1 (N7/10,5) 1 #ARR2 (N5/10,5) END-DEFINE * FOR #F = 1 TO 1000000 MOVE #ARR1(#I1,#I2) TO #ARR2(#J1,#J2) END-FOR * END
Option | CPU seconds | CPU percentage |
---|---|---|
OFF |
8.78 | 100 |
ON |
0.63 | 7.18 |
INDX |
0.85 | 9.68 |
OVFLW |
1.71 | 19.48 |
INDX,OVFLW |
2.00 | 22.78 |
INDX,OVFLW,NODBG |
1.61 | 18.34 |
INDX,OVFLW,NODBG,NOSGNTR |
1.61 | 18.34 |
NODBG |
0.44 | 5.01 |
NOSGNTR |
0.63 | 7.18 |
NODBG,NOSGNTR |
0.44 | 5.01 |
DEFINE DATA LOCAL 1 #I1 (P7) INIT <1> 1 #I2 (P7) INIT <2> 1 #J1 (N7) INIT <3> 1 #J2 (N7) INIT <4> 1 #K1 (I4) INIT <5> 1 #K2 (I4) INIT <6> 1 #F (I4) 1 #FIELD1 (P5) 1 #FIELD2 (N5) 1 #FIELD3 (I2) END-DEFINE * FOR #F = 1 TO 500000 * #FIELD1:= #I1 - #I2 + (13 * 10 / 5) #FIELD2:= #J1 - #J2 + (13 * 10 / 5) #FIELD3:= #K1 - #K2 + (13 * 10 / 5) * END-FOR * END
Option | CPU seconds | CPU percentage |
---|---|---|
OFF |
18.61 | 100.00 |
ON |
4.95 | 26.60 |
INDX |
4.95 | 26.60 |
OVFLW |
5.38 | 28.91 |
INDX,OVFLW |
5.38 | 28.91 |
INDX,OVFLW,NODBG |
5.26 | 28.26 |
INDX,OVFLW,NODBG,NOSGNTR |
5.09 | 27.35 |
NODBG |
4.79 | 25.74 |
NOSGNTR |
4.81 | 25.85 |
NODBG,NOSGNTR |
4.63 | 24.88 |
NODBG,NOSGNTR,ZD=OFF |
4.51 | 24.23 |
NODBG,NOSGNTR,ZD=OFF,SIGNCHCK=OFF |
4.41 | 23.70 |