getrusage
Description
The getrusage of Options / Information for PHP gets the current resource usages.
Syntax
getrusage(int $mode = 0): array|false
Parameters
mode
If mode is 1, getrusage will be called with RUSAGE_CHILDREN.
Return
Returns an associative array containing the data returned from the system call. All entries are accessible by using their documented field names. Returns false on failure.
Examples
1 · void
<? $return = getrusage(); print_r($return);
Array ( [ru_oublock] => 0 [ru_inblock] => 0 [ru_msgsnd] => 0 [ru_msgrcv] => 0 [ru_maxrss] => 12056 [ru_ixrss] => 0 [ru_idrss] => 0 [ru_minflt] => 187 [ru_majflt] => 0 [ru_nsignals] => 0 [ru_nvcsw] => 0 [ru_nivcsw] => 0 [ru_nswap] => 0 [ru_utime.tv_usec] => 0 [ru_utime.tv_sec] => 0 [ru_stime.tv_usec] => 1030 [ru_stime.tv_sec] => 0 )
2 · mode
<? $mode = 2; $return = getrusage($mode); print_r($return);
Array ( [ru_oublock] => 0 [ru_inblock] => 0 [ru_msgsnd] => 0 [ru_msgrcv] => 0 [ru_maxrss] => 13236 [ru_ixrss] => 0 [ru_idrss] => 0 [ru_minflt] => 230 [ru_majflt] => 0 [ru_nsignals] => 0 [ru_nvcsw] => 1 [ru_nivcsw] => 0 [ru_nswap] => 0 [ru_utime.tv_usec] => 0 [ru_utime.tv_sec] => 0 [ru_stime.tv_usec] => 1369 [ru_stime.tv_sec] => 0 )
3 · field names
<? $return = getrusage(); echo $return["ru_oublock"] . ": ru_oublock: number of block output operations\n"; echo $return["ru_inblock"] . ": ru_inblock: number of block input operations\n"; echo $return["ru_msgsnd"] . ": ru_msgsnd: number of IPC messages sent\n"; echo $return["ru_msgrcv"] . ": ru_msgrcv: number of IPC messages received\n"; echo $return["ru_maxrss"] . ": ru_maxrss: maximum resident set size\n"; echo $return["ru_ixrss"] . ": ru_ixrss: integral shared memory size\n"; echo $return["ru_idrss"] . ": ru_idrss: integral unshared data size\n"; echo $return["ru_minflt"] . ": ru_minflt: number of page reclaims (soft page faults)\n"; echo $return["ru_majflt"] . ": ru_majflt: number of page faults (hard page faults)\n"; echo $return["ru_nsignals"] . ": ru_nsignals: number of signals received\n"; echo $return["ru_nvcsw"] . ": ru_nvcsw: number of voluntary context switches\n"; echo $return["ru_nivcsw"] . ": ru_nivcsw: number of involuntary context switches\n"; echo $return["ru_nswap"] . ": ru_nswap: number of swaps\n"; echo $return["ru_utime.tv_usec"] . ": ru_utime.tv_usec: user time used (microseconds)\n"; echo $return["ru_utime.tv_sec"] . ": ru_utime.tv_sec: user time used (seconds)\n"; echo $return["ru_stime.tv_usec"] . ": ru_stime.tv_usec: system time used (microseconds)\n";
0: ru_oublock: number of block output operations 0: ru_inblock: number of block input operations 0: ru_msgsnd: number of IPC messages sent 0: ru_msgrcv: number of IPC messages received 12056: ru_maxrss: maximum resident set size 0: ru_ixrss: integral shared memory size 0: ru_idrss: integral unshared data size 195: ru_minflt: number of page reclaims (soft page faults) 0: ru_majflt: number of page faults (hard page faults) 0: ru_nsignals: number of signals received 0: ru_nvcsw: number of voluntary context switches 0: ru_nivcsw: number of involuntary context switches 0: ru_nswap: number of swaps 0: ru_utime.tv_usec: user time used (microseconds) 0: ru_utime.tv_sec: user time used (seconds) 1149: ru_stime.tv_usec: system time used (microseconds)
Links
Options / Information
- assert
- assert_options
- cli_get_process_title
- cli_set_process_title
- dl
- extension_loaded
- gc_collect_cycles
- gc_disable
- gc_enable
- gc_enabled
- gc_mem_caches
- gc_status
- get_cfg_var
- get_current_user
- get_defined_constants
- get_extension_funcs
- get_include_path
- get_included_files
- get_loaded_extensions
- get_required_files
- get_resources
- getenv
- getlastmod
- getmygid
- getmyinode
- getmypid
- getmyuid
- getopt
- ini_alter
- ini_get
- ini_get_all
- ini_parse_quantity
- ini_restore
- ini_set
- memory_get_peak_usage
- memory_get_usage
- memory_reset_peak_usage
- php_ini_loaded_file
- php_ini_scanned_files
- php_sapi_name
- php_uname
- phpcredits
- phpinfo
- phpversion
- putenv
- set_include_path
- set_time_limit
- sys_get_temp_dir
- version_compare
- zend_thread_id
- zend_version