This function is used to obtain statistical information on which statement lines of invoked Natural objects were executed. The function also provides information on how often an object was invoked and how often a statement line was executed.
Statement execution statistics can be used for the following purposes:
To detect dead (never gets executed) programming code in an application;
To estimate the coverage of an application test (how many statement lines have not been executed at least once for testing);
To locate frequently executed code segments that could have an impact on the application's performance.
To invoke the statement execution statistics maintenance function
In the Debug Main Menu, enter function code X.
Or:
Enter the following direct command:
XS
The Statement Execution Statistics Maintenance menu is displayed.
The functions provided in the Statement Execution Statistics Maintenance menu are explained in the following section whereas all print functions are described in Print Statements.
See the section Switch Test Mode On and Off.
This function is used to activate statistics about executed statement lines of Natural objects.
This section covers the following topics:
When executing a Natural object with statement execution
statistics set to ON or COUNT, all statement
lines executed within a specific object are listed in a statistical report.
With the option ON, the debugger only retains whether a specific statement
line was executed or not; with the option COUNT, it counts how often a
statement line was executed. You can specify a library and an object name to restrict
statement execution statistics to the desired Natural objects. The default is to collect
statistics for all objects of the current library. Asterisk (*) notation is
possible.
If you switch statement execution statistics from ON to COUNT
or vice versa, existing statistics are not affected, that is, their status of
ON or COUNT remains.
The statistical data collected is stored in the debug buffer. The amount of storage that is required to store statistical information for a Natural object is approximately
(number of source lines) / 8 + 100 bytes with statement
execution statistics set to ON and
(number of source lines) * 4 + 100 bytes with statement
execution statistics set to COUNT.
If you modify a Natural object by inserting or deleting lines and you do not renumber
the object lines before you STOW it, the amount of storage
required for the object's statistics may increase. To avoid this, set Auto
Renumber to Y (Yes) in your editor profile (see Editor
Profile in the Editors documentation), or
use the system command CATALL (see the System
Commands documentation) with the Renumber source-codes
lines option enabled (this is the default).
You can use the debugger command PROFILE (see Navigation and
Information Commands) to limit the size of the debug buffer. With statement execution statistics set to COUNT, no
statement execution statistics are collected for objects with more than 8000 statement
lines.
Statement execution statistics are part of the debug environment; therefore, they are
affected by the direct commands SAVE ENVIRONMENT and
LOAD ENVIRONMENT (see also the section Debug Environment
Maintenance).
This section provides instructions for activating or deactivating statement execution statistics.
You can specify a library and/or an object name to restrict statement execution statistics to the desired Natural objects. The default is to collect statistics for all objects of the current library. Asterisk (*) notation is possible.
To activate statement execution statistics
In the Statement Execution Statistics Maintenance menu,
enter function code S, the name of a library and/or the name of an
object. In the State field, change the value to
ON.
Or:
Enter one of the following direct commands:
SET XSTATISTICS ON library (object)
or
SET XSTATISTICS COUNT library (object)
See also the syntax of SET in Command Summary and
Syntax.
If you do not specify a library and/or an object, the statistics data about all objects in your current library are activated.
To deactivate statement execution statistics
In the Statement Execution Statistics Maintenance menu,
enter function code S, the name of a library and/or the name of an
object. In the State field, change the value to
OFF.
Or:
Enter the following direct command:
SET XSTATISTICS OFF library (object)
See also the syntax of SET in Command Summary and
Syntax.
If you do not specify a library and/or an object, the statistics data about all objects in your current library are deactivated.
To delete statement execution statistics
In the Statement Execution Statistics Maintenance menu, enter
function code C and the name of a library and/or the name of an object.
Or:
Enter the following direct command:
DELETE XSTATISTICS library (object)
See also the syntax of DELETE in Command Summary and
Syntax.
If you do not specify a library and/or an object, the statistics data about all objects in your current library are deleted.
This function invokes a screen with a list of the specified statement execution statistics.
To invoke the List Statement Execution Statistics screen
In the Statement Execution Statistics
Maintenance menu, enter function code D.
Or:
Enter the following direct command:
DISPLAY XSTATISTICS
The List Statement Execution Statistics screen is displayed:
16:02:01 ***** NATURAL TEST UTILITIES ***** 2002-02-15
Test Mode ON - List Statement Execution Statistics - Object
All
Co Object Library Type DBID FNR Obj.Called Exec Exec % Total No.
*_______ *_______ n Times able uted Executions
__ TEST SAG Program 10 32 4 20 17 85 95
__ MAP01 SAG Map 10 32 6 2 2 100 12
__ SPGM02 SAG Subprogram 10 32 2 6 2 33 4
__ SAGTEST1 SAG Program 10 32 2 20 10 50 17
__ DEBPGM SAG Program 10 32 1 6 6 100 34 |
For each object, the following information is displayed:
the call frequency;
the number of executable statements;
the number of executed statements;
the percentage of executed statements as related to the total number of executable statements;
the total number of executed statements.
A list entry is highlighted if data is missing or possibly inconsistent.
On the statistics list, you can mark an item with a line command for further processing:
| Line Command | Explanation |
|---|---|
DE |
Deletes statement execution statistics as described above. |
DS |
Displays all statement lines. |
DX |
Displays executed statement lines only. |
DN |
Displays non-executed statement lines only. |
I |
Displays information on the cataloged object and errors. |
PS |
Prints all statement lines. |
PX |
Prints executed statement lines only. |
PN |
Prints non-executed statement lines only. |
For further information on print functions, see Print Statements.
The following section describes the screens, which can be invoked with the display commands:
The Display Statement Lines screen shows the object source and indicates whether or not a statement line has been executed.
To invoke the Display Statement Lines screen
On the List Statement Execution
Statistics screen, mark an entry with the line command
DS.
Or:
Enter the following direct command:
DISPLAY STATEMENT library (object)
See also the syntax of DISPLAY in Command Summary and
Syntax.
The Display Statement Lines screen appears. If
statement execution statistics has been set to
COUNT, the execution frequency of the statement line is displayed
as shown in the example screen below:
16:04:01 ***** NATURAL TEST UTILITIES ***** 2002-02-15 Test Mode ON - Display Statement Lines - Object SAGTEST Line Source Count 0200 RD1. READ EMPLOYEES-VIEW BY NAME 2 0210 STARTING FROM #NAME-START THRU #NAME-END 0220 * 0230 IF LEAVE-DUE >= 20 1 0240 PERFORM MARK-SPECIAL-EMPLOYEES not executed 0250 ELSE not executed 0260 RESET #MARK 1 0270 END-IF 0280 * 0290 RESET #MAKE #MODEL 1 0300 CALLNAT 'SPGM02' PERSONNEL-ID #MAKE #MODEL 1 0310 * 0320 WRITE TITLE / '*** PERSONS WITH 20 OR MORE DAYS LEAVE DU 1 0330 / '*** ARE MARKED WITH AN ASTERISK ***' // 0340 DISPLAY '//N A M E' NAME 2 |
If no unique object has been specified, the List Statement Execution Statistics screen is displayed.
The Display Executed Statement Lines screen corresponds to the Display Statement Lines screen, but only the statement lines that have been executed are displayed.
To invoke the Display Executed Statement Lines screen
On the List Statement Execution Statistics screen, mark an
entry with the line command DX.
Or:
Enter the following direct command:
DISPLAY EXEC library (object)
See also the syntax of DISPLAY in Command Summary and
Syntax.
If no unique object has been specified, the List Statement Execution Statistics screen is displayed.
The Non-Executed Statement Lines screen corresponds to the Display Statement Lines screen, but only the statement lines that have not been executed are displayed.
To invoke the Display Non-Executed Statement Lines screen
On the List Statement Execution Statistics screen, mark an
entry with the line command DN.
Or:
Enter the following direct command:
DISPLAY NOEXEC library (object)
See also the syntax of DISPLAY in Command Summary and
Syntax.
If no unique object has been specified, the List Statement Execution Statistics screen is displayed.
With the print functions, you can directly route a generated list of statement execution
statistics to a printer or download the list to a PC. You define a printer as the output
device on the User Profile screen of the debugger. Use the debugger
command PROFILE (see
the section Navigation and Information Commands) to invoke this
screen.
If you do not specify a library name, the library where you are currently logged on is assumed by default.
As indicated under Print Options below, to invoke one of the print functions, you can either enter a function code in the Statement Execution Statistics Maintenance menu, enter a line command on the Display Statement Lines screen or enter a direct command.
| Print Function | Function Code | Line Command | Direct Command |
|---|---|---|---|
| Print statement execution statistics | PRINT XSTATISTICS library
(object)
|
||
| Print all statements | PS |
PRINT STATEMENT library
(object)
|
|
| Print executed statements | PX |
PRINT EXEC library
(object)
|
|
| Print non-executed statements | PN |
PRINT NOEXEC library
(object)
|
See also the syntax of PRINT in the section Command Summary
and Syntax.
Example of a PC Download in Print Objects in the section Call Statistics Maintenance
Example of Generating and Printing Statistics in Batch in the section Batch Processing