Use the $TIME() function to obtain the current time of day (TOD) clock value, add and subtract double-word unsigned binary values, and convert CPU timer values to printable strings.
The $TIME() function has this syntax:
Form 1:
$TIME(ADD,value1,value2)
Form 2:
$TIME(FULL,value1)
Form 3:
$TIME(FULLB,value1)
Form 4:
$TIME(SEC,value1)
Form 5:
$TIME(STCK)
Form 6:
$TIME(SUB,value1,value2)
The $TIME() function takes these arguments:
Adds value1 to value2. The result is an unsigned 8-byte binary value in IBM TOD clock format.
Subtracts value2 from value1. The result is an unsigned 8-byte binary value in IBM TOD clock format.
8-byte binary string in IBM TOD clock format.
8-byte binary string in IBM TOD clock format to be added to or subtracted from value1.
Converts value1 to a printable string in the format hh:mm:ss.tho (hh is hours, mm is minutes, ss is seconds, and tho is thousandths of a second). The string is always 12 bytes in length and all leading zeros and field separators are present.
Same as FULL, except that leading zeros and punctuation are replaced by blanks.
Converts value1 to seconds. Returned number is in REXX format, contains a decimal point, and is accurate to thousandths of a second.
Returns the current value of the system TOD clock as an 8-byte unsigned binary value.
The $TIME() function produces these return codes:
ARG n MISSING OR INVALID
Example 1
/* Report total CPU usage for an address space */
parse arg ascb /* address of ASCB is passed */
cpu = memory('f',ascb+64,8) /* get elapsed jobstep time (ASCBEJST */
string = $time('full',cpu) /* convert to printable string */
return string
Example 2
/* Determine elapsed CPU time for subroutine */
start = cpu('stck') /* obtain start CPU value */
call test_sub /* invoke subroutine to time */
stop = cpu('stck') /* obtain ending CPU value */
total = $time('sub',stop,start) /* determine elapsed CPU time */
string = $time('fullb',total) /* make printable. no lead zeros. */
say 'Subroutine CPU: ' string
| Copyright © 2012 CA. All rights reserved. | Tell Technical Publications how we can improve this information |