php8.5
Home/ Manual/ posix / functions/ posix_times

posix_times

PHP function Edit on GitHub ✎

(PHP 4, PHP 5, PHP 7, PHP 8)

Get process times

Description

posix_times(): array|false

Gets information about the current CPU usage.

Parameters Parameters

Return Values

Returns a hash of strings with information about the current process CPU usage. The indices of the hash are:

  • ticks - the number of clock ticks that have elapsed since reboot.
  • utime - user time used by the current process.
  • stime - system time used by the current process.
  • cutime - user time used by current process and children.
  • cstime - system time used by current process and children.

The function returns false on failure.

Examples

Example use of posix_times()

php
<?php

$times = posix_times();

print_r($times);
?>

The above example will output something similar to:

output
Array
(
    [ticks] => 25814410
    [utime] => 1
    [stime] => 1
    [cutime] => 0
    [cstime] => 0
)

Notes

Warning

This function isn't reliable to use, it may return negative values for high times.

Source: reference/posix/functions/posix-times.xml · from the official PHP manual (php/doc-en)