Previous Topic: Writing to the Journal FileNext Topic: Sending Messages


Collecting DC Statistics

You can collect run-time statistics related to DC transactions on a logical terminal. This information can be useful both for debugging purposes and as an aid in determining overall program efficiency.

Steps to Collect Statistics

To collect run-time DC statistics related to the transactions performed on a logical terminal, perform the following steps:

  1. Establish a 248-byte field in program variable storage in which to copy the transaction statistics.
  2. Define the beginning of the transaction by issuing a BIND TRANSACTION STATISTICS statement.
  3. Perform pseudoconversational processing, as required.
  4. Copy the contents of the transaction statistics block (TSB) into the specified location in variable storage and, optionally, to the DC log file by issuing an ACCEPT TRANSACTION STATISTICS statement.
  5. When processing is complete, terminate statistics collection by issuing an END TRANSACTION STATISTICS statement, optionally writing the statistics to variable storage and the DC log file.

Example of Collecting Transaction Statistics

Depending on the invoking task, the program excerpt below initiates statistics collection, copies the TSB to the DC log file, or terminates statistics collection and displays selected statistics on the terminal screen.

DATA DIVISION
WORKING-STORAGE SECTION.
  01  TASKCODE                   PIC X(8).
      88 FIRSTTIME               VALUE 'INIT'.
      88 SECONDTIME              VALUE 'TRANS'.
      88 FINALTIME               VALUE 'TERMSESS'.
  01  STATISTICS-BLOCK.
      05 USER-ID                 PIC X(32).
      05 LTERM-ID                PIC X(8).
      05 PROG-CALL               PIC S9(8) COMP.
      05 PROG-LOAD               PIC S9(8) COMP.
      05 TERM-READ               PIC S9(8) COMP.
      05 TERM-WRITE              PIC S9(8) COMP.
      05 TERM-ERROR              PIC S9(8) COMP.
      05 STORAGE-GET             PIC S9(8) COMP.
      05 SCRATCH-GET             PIC S9(8) COMP.
      05 SCRATCH-PUT             PIC S9(8) COMP.
      05 SCRATCH-DEL             PIC S9(8) COMP.
      05 QUEUE-GET               PIC S9(8) COMP.
      05 QUEUE-PUT               PIC S9(8) COMP.
      05 QUEUE-DEL               PIC S9(8) COMP.
      05 GET-TIME                PIC S9(8) COMP.
      05 SET-TIME                PIC S9(8) COMP.
      05 DB-CALLS                PIC S9(8) COMP.
      05 MAX-STACK               PIC S9(8) COMP.
      05 USER-TIME               PIC S9(8) COMP.
      05 SYS-TIME                PIC S9(8) COMP.
      05 WAIT-TIME               PIC S9(8) COMP.
      05 PAGES-READ              PIC S9(8) COMP.
      05 PAGES-WRIT              PIC S9(8) COMP.
      05 PAGES-REQ               PIC S9(8) COMP.
      05 CALC-NO                 PIC S9(8) COMP.
      05 CALC-OF                 PIC S9(8) COMP.
      05 VIA-NO                  PIC S9(8) COMP.
      05 VIA-OF                  PIC S9(8) COMP.
      05 RECS-REQ                PIC S9(8) COMP.
      05 RECS-CURR               PIC S9(8) COMP.
      05 FILLER                  PIC X(4).
      05 FRAG-STORED             PIC S9(8) COMP.
      05 RECS-RELO               PIC S9(8) COMP.
      05 TOT-LOCKS               PIC S9(8) COMP.
      05 SEL-LOCKS               PIC S9(8) COMP.
      05 UPD-LOCKS               PIC S9(8) COMP.
      05 STG-HI-MARK             PIC S9(8) COMP.
      05 FREESTG-REQ             PIC S9(8) COMP.
      05 SYS-SERV                PIC S9(8) COMP.
      05 RESERVED                PIC X(40).
      05 USER-SUPP-ID            PIC X(8).
      05 BIND-DATE               PIC S9(7) COMP-3.
  01  STAT-DIS.
      05 WORK-CURR-DATE          PIC 9(5).
      05 WORK-USER-ID            PIC X(32).
      05 WORK-DB-CALLS           PIC 9(4).
      05 WORK-WAIT-TIME          PIC 9(12).
      05 WORK-PAGES-READ         PIC 9(5).
      05 WORK-PAGES-WRIT         PIC 9(5).
  PROCEDURE DIVISION.
      BIND MAP STATMAP.
      BIND MAP STATDIS RECORD STATISTICS-BLOCK.
 *
      ACCEPT TASK CODE INTO TASKCODE.
 *** FIRST TIME, INITIATE STATISTICS COLLECTION ***
      IF FIRSTTIME
         BIND TRANSACTIONS STATISTICS
         DC RETURN.
 *** SUBSEQUENT TIMES, COPY STATISTICS TO VARIABLE STORAGE ***
      IF SECONDTIME
         ACCEPT TRANSACTION STATISTICS
           WRITE INTO STATISTICS-BLOCK
         DC RETURN.
 *** LAST TIME, END STATISTICS COLLECTION AND ***
 *** COPY STATISTICS TO VARIABLE STORAGE      ***
      IF FINALTIME
         END TRANSACTION STATISTICS
           WRITE INTO STATISTICS-BLOCK
         PERFORM U100-MOVE-FIELDS-TO MAP
         MAP OUT USING STATMAP
             MESSAGE IS STAT-DISPLAY-MESS LENGTH 40
         DC RETURN.
       DC RETURN.