%CPUTIME

Return the accumulated CPU time

WSupported on Windows
USupported on Unix
VSupported on OpenVMS
NSupported in Synergy .NET
cpu_time = %CPUTIME

Return value

cpu_time

The CPU time accumulated by the current process. The returned value represents the number of 10 millisecond intervals (tics) accumulated. (i)

Discussion

%CPUTIME is evaluated at runtime. It is functionally equivalent to the CPUTM subroutine, but we recommend you use %CPUTIME because functions are, generally speaking, more efficient than subroutines.

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.

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:")
    last = %cputime   ; Get the time at startup
    xcall doit        ; Do some processing here
    now = %cputime    ; Get the time at the end
    writes(1, "Elapsed time = " + %string(now - last))
    close 1
    stop
end