CPUTM

Return the accumulated CPU time

WSupported on Windows
USupported on Unix
VSupported on OpenVMS
NSupported in Synergy .NET
xcall CPUTM(time)

Arguments

time

Returned with the accumulated CPU time. The returned value represents the number of 10 millisecond intervals (tics) accumulated. (n)

Discussion

The CPUTM subroutine returns the CPU time accumulated by the current process.

On Windows, the time is elapsed time, not accumulated system time.

On Unix, the CPU time accumulated includes CPU time for all child processes that the runtime waits for (for example, XCALL SPAWN and XCALL SHELL, but not XCALL RUNJB).

CPU time is accumulated for an entire process, not for a program or programs within the process.

The CPU time is not zeroed out at the beginning of a Synergy program. To measure the CPU time consumed by a program, you must sample the CPU time at program startup and again at the checkpoint, and then subtract the first value from the second.

Tip

The CPUTM subroutine is functionally equivalent to the %CPUTIME function. We recommend you use %CPUTIME instead of CPUTM because functions are, generally speaking, more efficient.

Examples

The following example measures the time consumed by the “doit” routine.

record
    last        ,i4
    now         ,i4
proc
    xcall flags(1001010, 1)
    open(1, o, "TT:")
    xcall cputm(last)    ; Get the time at startup
    xcall doit           ; Do some processing here
    xcall cputm(now)     ; Get the time at the end
    writes(1, "Elapsed time = " + %string(now - last))
    close 1
    stop
end