Joined: 09 Mar 2011
|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.
| ID DIVISION.
01 W-PSA-POINTER POINTER.
05 FILLER PIC X(548).
05 PSA-CB-ASCB-POINTER POINTER.
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
SET ADDRESS OF ASCB-CONTROL-BLOCK
SET L-CPU-TIME-PTR TO ADDRESS OF ASCB-CB-CPUTIME