NOCSTAT Command

For programs optimized with the Natural Optimizer Compiler, certain statements can be directly converted into machine code when cataloged. As a result, when executing the optimized objects with Natural at runtime, the performance can be improved considerably.

The NOCSTAT command analyses cataloged objects and provides statistical information to help decide whether program statements benefit from optimization with the Natural Optimizer Compiler and, if so, to what extent they can be optimized.

If a program is cataloged (STOW, CATALL), the Natural compiler generates an internal (pseudo) object code based on the statements in the source program. In most cases, one source statement is transformed into one pseudo-code instruction. However, for complex statements, such as FOR and REPEAT, several pseudo-code instructions are generated. The NOCSTAT analyses are based on the generated pseudo-code instructions. Therefore, the number of statements indicated in the statistical reports may exceed the number of statements in the source program.

This document covers the following topics:


Invoking NOCSTAT

Start of instruction setTo use the Natural NOCSTAT command  

  • Enter the direct command NOCSTAT.

    The main NOCSTAT screen is displayed:

    16:05:43             ***** NATURAL NOCSTAT COMMAND *****             2017-05-29
                                                                                   
                                                                                   
    Name .................. ________                                               
    Library ............... SAGTEST_                                               
                                                                                   
    NOCable Objects only .. _                                                      
                                                                                   
    Output Report ......... X Statement Category                                   
                            _ Statement Type                                       
                            _ Code Profile                                         
                                                                                   
    Output Destination .... X Screen                                               
                            _ CSV to Work File                                     
                            _ XML to Work File                                     
                              with XSL ________________________________            
                                                                                   
    Progress Control ...... X                                                      
    Download to PC ........ _                                                      
                                                                                   
    
                                                                                   
    Command ===>                                                                   
    
                                                                                   
    Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12---
          Help        Exit                                                  Canc

To obtain field-specific help information, either enter a question mark in the relevant field and press ENTER, or place the cursor in the field and press PF1. Press PF3 to exit NOCSTAT

Generating Reports

You can generate statistical reports for a single program or a set of programs. If you analyze more than one program at a time, the reports are produced in series. When you have finished looking at one report, press ENTER to view the next report. 

The main NOCSTAT menu provides the following options:

Field  Explanation
Name Enter a name or a range of names to specify the program(s) you want to examine:
value is any combination of one or more characters.
value Single program.
* All programs.
value* All programs whose names begin with value.
value> All programs whose names are greater/equal value.
value< All programs whose names are less/equal value.
Library Enter the name of a library or specify a range; the same applies as described for the Name field above.

The current library is the default.

NOCable
Objects only

Mark this option to exclude programs already compiled with the Natural Optimizer Compiler.

Otherwise, the NOCSTAT command selects all Natural programs specified in the Name and Library fields by default, including NOC-compiled programs.

Output Report Mark any of  the options to select statements by category, type or code profile. 

See Statement Category, Statement Type and Code Profile below.

Output Destination Mark any of the following options to determine the output format and destination:  
Screen Displays the report on the screen or writes the report data to Print File 7 if Download to PC is selected for processing.
CSV to 
Work File
Generates spreadsheets with comma-separated values.

The report data is written to either of the following files:

  1. Work File 7 if running online and Download to PC is selected.

  2. Work File 1 in all other cases.

Use the file extension .csv to write the work file directly to your PC for further processing.

You can only route reports to a PC if Entire Connection is installed. 

XML to
Work File
Generates XML documents. 

The report data is written to either of the following files:

  1. Work File 7 if running online and Download to PC is selected.

  2. Work File 1 in all other cases.

Use the file extension .txt to write the work file data directly to your PC and change the file name afterwards to the extension .xml for further processing.

You can only route reports to a PC if Entire Connection is installed.

If a value is entered in the field with XSL, a processing instruction is added at the top of the XML output document:

<?xml-stylesheet type="text/xsl" href="
value "?>

The value entered should be the absolute or relative URL of the style sheet, for example:

nocstat.xsl

or

http://natural.software-ag.de/nocstat.xsl

The processing instruction causes the document to be transformed according to the given style sheet when it is viewed by an XSLT-capable browser or transformed by a batch XSLT run. A typical use of this feature is to convert the output XML to an HTML page. 

There are two XSLT style sheets delivered with Natural as text objects NOCSTLS1 and NOCSTLS2 in the Natural library SYSEXUEX in the FNAT system file.

NOCSTLS1 provides formatting instructions for report type Statement Category, NOCSTLS2 for report type Statement Type as described below.

Download the style sheets with file extension .xsl to the same directory in which the XML work files are stored.

Progress Control Only applies in an online environment and if one of the following options is selected for processing:
  1. CSV to Work File,

  2. XML to Work File,

  3. Download to PC.

If one of these options is selected, a brief message appears for each program listed in the generated report.

Download to PC Only applies if Entire Connection is installed, and if you run online with Print/Work File 7 defined as the PC file (see the WORK and PRINT profile parameters).

Download report output data with Entire Connection to a PC by using either of the following:

  1. Print File 7 for the Screen destination.

  2. Work File 7 for CSV or XML output.

Report Formats

You can choose between three output formats described below to display the statistics NOCSTAT provides for the statements analyzed. Different report layouts are produced for programs already optimized with the Natural Optimizer Compiler and for programs to be considered for optimization. The example reports below show the difference. Press PF3to interrupt report processing and return to the NOCSTAT menu.

Below is information on:

Statement Category

The statistical report generated with the option Statement Category lists various categories of statements with the corresponding number of occurrences and the total number of statements already optimized or suitable for optimization, depending on whether or not the program was optimized with the Natural Optimizer Compiler. 

Example of Program without NOC Optimization:

11:49:46             ***** NATURAL NOCSTAT COMMAND *****             2017-05-29
                Library SAGTEST  Name NOCTEST1 Type Program                    
                                                                               
                                                                               
                      No NOC      NOCable                                      
                     --------     --------                                     
      Database Loop:        0            0                                     
    Database Simple:        0            0                                     
    SORT / WORK I/O:        0            0                                     
       FOR / REPEAT:        0            1                                     
   Screen / Printer:        1            0                                     
String Manipulation:        6           34                                     
    Arith / Logical:        0          996                                     
      Program Calls:       20            0                                     
   Control Transfer:        2          182                                     
        Block Start:        1            0                                     
    Set Environment:        7            0                                     
   System Functions:        2            0                                     
      Miscellaneous:        0            1                                     
                                                                               
                Total Statements:     1254                                     
                 NOC optimizable:     1214  ( Ratio:  96 % )                   
                 Longest NOC Run:      216  Statements

Example of NOC-Optimized Program:

11:51:25             ***** NATURAL NOCSTAT COMMAND *****             2017-05-29
                Library SAGTEST  Name NOCTEST1 Type Program                    
                                                                               
     MCG Options: (ON,OVFLW,INDX,MIX,IO)                                       
                                                                               
                                                                               
      Database Loop:        0                                                  
    Database Simple:        0                                                  
    SORT / WORK I/O:        0                                                  
       FOR / REPEAT:        0                                                  
   Screen / Printer:        1                                                  
String Manipulation:       36                                                  
    Arith / Logical:        0                                                  
      Program Calls:       20                                                  
   Control Transfer:        2                                                  
        Block Start:        1                                                  
    Set Environment:        7                                                  
   System Functions:        2                                                  
      Miscellaneous:        1                                                  
                                                                               
   Total Statements:     1255                                                  
      NOC optimized:     1185  ( Ratio:  94 % )                                
    Longest NOC Run:      136  Statements

Report Columns and Fields:

Column Explanation
No NOC Statements not suitable for optimization.
NOCable Statements suitable for optimization.

Note:
The number of NOCable statements is only a reasonable assumption but cannot be considered an absolutely reliable value. This is because the NOCSTAT command cannot perform all analytical queries and, occassionally, very complex code investigations that definitely decide whether a statement can be optimized with the Natural Optimizer Compiler.

Field  
Database Loop The number of database statements that generate a processing loop, such as FIND and READ
Database Simple Database statements that do not generate a processing loop, such as STORE, UPDATE, DELETE and GET.
SORT / WORK I/O SORT and work file statements.
FOR / REPEAT Statements generating loops.
Screen / Printer Screen and printer I/O, such as WRITE, DISPLAY and INPUT.
String Manipulation String statements, such as EXAMINE and COMPRESS.
Arith / Logical Arithmetic and logical statements, such as MOVE, COMPUTE and IF.
Program Calls Transfer of control to a subroutine or subprogram, such as PERFORM, CALLNAT and FETCH.
Control Transfer Jumps within the program, such as ESCAPE BOTTOM, FOR and REPEAT loops. 
Block Start Non-executed statements that demarcate code blocks, such as DEFINE SUBROUTINE and AT END. These statements are never optimized because they are never executed. 
Set Environment Statements that set the environment, such as SET CONTROL, SET GLOBALS and SET KEY.
System Functions Statements, such as TOTAL, SUM, COUNT, MAX, MIN and *COUNT.
Miscellaneous Pseudo-code statements not relevant for optimization and, therefore, ignored by the NOC.
Totals  
Total Statements The total number of  statements found in the program. This number may not correspond to the actual source statements as described in the introduction to NOCSTAT command above.
NOC optimized For an optimized program, these are the actual pseudo-code statements (as described in the introduction to NOCSTAT command above) that have been NOC-optimized to machine code.
NOC optimizable For non-optimized programs, this is the possible number of statements that could be optimized. The figure may be slightly higher than the actual number, since certain factors are not considered in the NOCSTAT program. For example, a SUBSTRING statement that has more than four arrays will be indicated as "optimizable" though it will not be optimized.
Ratio Relation between Total Statements and NOC-optimized statements or Total Statements and NOC-optimizable statements in percent.
Longest NOC Run NOC-optimized program:

The number of contiguous optimized statements -  the fewer fragment sequences, the better the performance.

Non-optimized program:

The number of contiguous statements to be expected if the program were optimized.

Statement Type

The statistical report generated with the option Statement Type lists single statements with the corresponding number of occurrences and the NOC coding generated for optimized objects.

Example of Program without NOC Optimization:

12:29:23             ***** NATURAL NOCSTAT COMMAND *****             2017-05-29
                Library SAGTEST  Name NOCTEST1 Type Program                    
                                                                               
       Statement            No NOC   NOCable                                   
------------------------   --------  --------                                  
MOVE/COMPUTE/ASSIGN               0       615                                  
EXAMINE                           6         0                                  
SEPARATE                          0        30                                  
COMPRESS                          0         4                                  
MOVE TO SYSTEM FUNCTION           2         0                                  
CALLNAT/PERFORM EXTERNAL         17         0                                  
MOVE EDITED                       1         0                                  
ELSE/CLOSE LOOP                   0       182                                  
ON ERROR                          1         0                                  
END                               1         0                                  
STOP                              1         0                                  
IF                                0        51                                  
IF IN REPEAT UNTIL                0         1                                  
REPEAT                            0         1                                  
RESET                             0        74                                  
IF                                0       255                                  
FETCH                             3         0                                  
IGNORE                            0         1                                  
STACK TOP CMD/DATA                2         0                                  
MCG OPTIONS                       1         0                                  
OPTIONS                           1         0                                  
SET CONTROL                       4         0

Example of NOC-Optimized Program:

12:31:30             ***** NATURAL NOCSTAT COMMAND *****             2017-05-29
                Library SAGTEST  Name NOCTEST1 Type Program                    
     MCG Options: (ON,OVFLW,INDX,MIX,IO)                                       
       Statement            Number                                             
------------------------   --------                                            
EXAMINE                           6                                            
SEPARATE                         30                                            
MOVE TO SYSTEM FUNCTION           2                                            
CALLNAT/PERFORM EXTERNAL         17                                            
MOVE EDITED                       1                                            
NOC CODE                       1183                                            
ON ERROR                          1                                            
END                               1                                            
STOP                              1                                            
FETCH                             3                                            
IGNORE                            1                                            
STACK TOP CMD/DATA                2                                            
MCG OPTIONS                       2                                            
OPTIONS                           1                                            
SET CONTROL                       4

Code Profile

The statistical report generated with the option Code Profile displays contiguous sequences of statements grouped by categories in a source program suitable for optimization, or lists the NOC coding generated for an optimized program. Occurrences are highlighted.

Example of Program without NOC Optimization:

12:38:52             ***** NATURAL NOCSTAT COMMAND *****             2017-05-29
                Library SAGTEST  Name NOCTEST1 Type Program            
                                                                               
Line   Statement                                                               
-----  -------------------------                                               
0000   ON ERROR                                                                
0000   MCG OPTIONS                                                             
0000   OPTIONS                                                                 
0295   CALLNAT/PERFORM EXTERNAL                                                
0295   MOVE/COMPUTE/ASSIGN       <-- NOCable                                   
0295   MOVE/COMPUTE/ASSIGN       <-- NOCable                                   
0295   MOVE/COMPUTE/ASSIGN       <-- NOCable                                   
0295   MOVE/COMPUTE/ASSIGN       <-- NOCable                                   
0740   MOVE/COMPUTE/ASSIGN       <-- NOCable                                   
0745   IF                        <-- NOCable                                   
0750   MOVE/COMPUTE/ASSIGN       <-- NOCable                                   
0755   MOVE/COMPUTE/ASSIGN       <-- NOCable                                   
0760   CALLNAT/PERFORM EXTERNAL                                                
0765   IF                        <-- NOCable                                   
0770   MOVE/COMPUTE/ASSIGN       <-- NOCable                                   
0775   ELSE                      <-- NOCable                                   
0780   MOVE/COMPUTE/ASSIGN       <-- NOCable                                   
0810   RESET                     <-- NOCable                                   
MORE

Example of NOC-Optimized Program:

12:39:47             ***** NATURAL NOCSTAT COMMAND *****             2017-05-29
                Library SAGTEST  Name NOCTEST1 Type Program            
                                                                               
Line   Statement                                                               
-----  -------------------------                                               
0000   MCG OPTIONS                                                             
0005   MCG OPTIONS                                                             
0000   OPTIONS                                                                 
0295   CALLNAT/PERFORM EXTERNAL                                                
0295   NOC CODE                                                                
0295   NOC CODE                                                                
0295   NOC CODE                                                                
0295   NOC CODE                                                                
0740   NOC CODE                                                                
0745   NOC CODE                                                                
0750   NOC CODE                                                                
0755   NOC CODE                                                                
0760   CALLNAT/PERFORM EXTERNAL                                                
0765   NOC CODE                                                                
0770   NOC CODE                                                                
0775   NOC CODE                                                                
0780   NOC CODE                                                                
0810   NOC CODE                                                                
MORE

Batch Execution

Below are job examples for processing NOCSTAT reports in batch mode to create a CSV work file. After job execution, the work files generated can be transferred from host to PC for further processing with standard transfer tools.

Example Job z/OS:

  //NOCBATCH JOB  (NOC,,,30),CLASS=K,MSGCLASS=X                           00000100
  //NATEX EXEC PGM=NATvrsBA,REGION=6200K,PARM=('IM=D')                    00000200
  //STEPLIB  DD DISP=SHR,DSN=TESTNAT.LOAD                                 00000300
  //CMPRINT  DD SYSOUT=X                                                  00000400
  //CMWKF01  DD DSN='NOC.NOCSTAT.OUT',DISP=(NEW,CATLG),                   00000500
                SPACE=(CYL,(1,1)),UNIT=SYSDA,VOL=SER=SAG001               00000600
  //SYSOUT   DD SYSOUT=X                                                  00000700
  //CMSYNIN  DD *                                                         00000800
  NOCSTAT                                                                 00000900
  *,library,,X,,,,X                                                       00001000
  .                                                                       00001100
  FIN                                                                     00001200
  /*                                                                      00001300

Example Job z/VSE:

  * $$ JOB JNM=NOCTST,CLASS=5,DISP=D
  * $$ LST CLASS=Q,DISP=D
  // JOB NOCTST
  // ASSGN SYS001,DISK,VOL=xxxxxx,SHR
  // DLBL CMWKF01,'NOCSTAT.FILE.ONE',0
  // EXTENT SYS001,xxxxxx,1,0,1,150
  // EXEC NATvrsBA,SIZE=NATvrsBA,PARM='SYSRDR'
  IM=D,OBJIN=R
  /*
  ADARUN DBID=185
  /*
  NOCSTAT
  *,library,,X,,,,X
  .
  FIN
  /*
  /&

Example Job BS2000:

  /.BAT234 LOGON  NAT,1      
  /        SYSFILE SYSOUT=NATvrs.OUT
  /        SYSFILE SYSLST=NATvrs.LST
  /SKIP   .NOP000                                                                
  ======================================================================          
        NAME   : E.NATvrs          S T A R T  B A T C H   N A T U R A L           
  ======================================================================          
  /.NOP000 REMARK                                                                 
  /        OPTION  DUMP=YES,MSG=FL
  /        FILE    NOCSTAT.OUT,LINK=W01
  /        FILE    ADAUSER  ,LINK=DDCARD                                      
  /        FILE    $SAG.ADAvrs.MOD       ,LINK=BLSLIB00 
  /        SYSFILE TASKLIB=MODvrs     
  /        SYSFILE SYSDTA=(SYSCMD)
  /        FILE    NATvrs.CMPRMIN,LINK=CMPRMIN
  /        DCLJV   NATJV1,LINK=*NATB2JV
  /        FILE    $NAT.ADALNK.PARMS,LINK=DDLNKPAR                                
  /        REMARK  %%%%%%%%%%  BATCH-PHASE   %%%%%%%%%%%%%%   
  /        EXEC    NATvrs                                                   
  NOCSTAT
  *,library,,X,,,,X
  .
  FIN