Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
With the usual provisos (don't use in production, don't rely on it being available after z/OS upgrade) here is a module which will make the CPU time available in the program which calls it (or wherever the storage happens to be defined).
At the "front" of a program,
CALL "BBPFTC1" USING ADDRESS OF a-doubleword-binary-defined-in-linkage
Then forget about the sub-program, no longer needed. You could, I suppose, even CANCEL it if you've loaded it dynamically.
When you need the CPU time, just use the field from Linkage. Typically, save it before a suspect block of code. Save it somewhere else after the block. Compare. To get the time "big enough", "divide by 4096" to get it to miliseconds.
Code: |
ID DIVISION.
PROGRAM-ID. BBPFTC1.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 W-PSA-POINTER POINTER.
LINKAGE SECTION.
01 PSA-CONTROL-BLOCK.
05 FILLER PIC X(548).
05 PSA-CB-ASCB-POINTER POINTER.
01 ASCB-CONTROL-BLOCK.
05 FILLER PIC X(64).
05 ASCB-CB-CPUTIME PIC X(8).
01 L-CPU-TIME-PTR USAGE POINTER.
PROCEDURE DIVISION USING L-CPU-TIME-PTR.
SET W-PSA-POINTER TO NULL
SET ADDRESS OF PSA-CONTROL-BLOCK
TO W-PSA-POINTER
SET ADDRESS OF ASCB-CONTROL-BLOCK
TO PSA-CB-ASCB-POINTER
SET L-CPU-TIME-PTR TO ADDRESS OF ASCB-CB-CPUTIME
GOBACK
.
|
|
|