[ Operating System | Reference Manual | Alphabetic Index ]


Returns the calling thread's cpu time
Float number or variable.


Used to find the cpu time that the calling thread has consumed, in seconds. It is equivalent to statistics(cputime, Time).

Whether this time includes 'system' cputime (i.e. time spent in system calls on behalf of the thread) depends on the operating system. E.g., for Linux system time is included, for Windows it is not.

The granularity of this timer also varies depending on the operating system and/or hardware. It can be as coarse as 1/60 or 1/50 of a second. Hence if you use cputime/1 to measure runtimes make sure that the measured intervals are long enough. Alternatively, if supported, use statistics(hr_time,Time).

To obtain the cputime for the whole process (all threads), use statistics(times, [UserCpu,SystemCpu|_]).

Note that (like all predicates that return a number as their last argument), this predicate can be used as a function inside arithmetic expressions.

Modes and Determinism


   [eclipse]: cputime(T).
   T = 0.0333333


See Also

statistics / 0, statistics / 2, date / 1, get_flag / 2