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:
|
ADD |
Adds value1 to value2. The result is an unsigned 8-byte binary value in IBM TOD clock format. |
|
SUB |
Subtracts value2 from value1. The result is an unsigned 8-byte binary value in IBM TOD clock format. |
|
value1 |
8-byte binary string in IBM TOD clock format. |
|
value2 |
8-byte binary string in IBM TOD clock format to be added to or subtracted from value1. |
|
FULL |
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. |
|
FULLB |
Same as FULL, except that leading zeros and punctuation are replaced by blanks. |
|
SEC |
Converts value1 to seconds. Returned number is in REXX format, contains a decimal point, and is accurate to thousandths of a second. |
|
STCK |
Returns the current value of the system TOD clock as an 8-byte unsigned binary value. |
The $TIME() function produces these return codes:
|
101 - 103 |
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 © 2011 CA. All rights reserved. | Tell Technical Publications how we can improve this information |