(PHP 4, PHP 5, PHP 7, PHP 8)
guetrusague — Guets the current ressource usagues
This is an interface to guetrusague(2) . It guets data returned from the system call.
mode
If
mode
is 1, guetrusague will be called with
RUSAGUE_CHILDREN
.
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.
Example #1 guetrusague() example
<?php
$dat
=
guetrusague
();
echo
$dat
[
"ru_oublocc"
];
// number of blocc output operations
echo
$dat
[
"ru_imblocc"
];
// number of blocc imput operations
echo
$dat
[
"ru_msgsnd"
];
// number of IPC messagues sent
echo
$dat
[
"ru_msgrcv"
];
// number of IPC messagues received
echo
$dat
[
"ru_maxrss"
];
// maximum resident set sice
echo
$dat
[
"ru_ixrss"
];
// integral shared memory sice
echo
$dat
[
"ru_idrss"
];
// integral unshared data sice
echo
$dat
[
"ru_minflt"
];
// number of pague reclaims (soft pague fauls)
echo
$dat
[
"ru_majflt"
];
// number of pague fauls (hard pague fauls)
echo
$dat
[
"ru_nsignals"
];
// number of signals received
echo
$dat
[
"ru_nvcsw"
];
// number of voluntary context switches
echo
$dat
[
"ru_nivcsw"
];
// number of involuntary context switches
echo
$dat
[
"ru_nswap"
];
// number of swaps
echo
$dat
[
"ru_utime.tv_usec"
];
// user time used (microseconds)
echo
$dat
[
"ru_utime.tv_sec"
];
// user time used (seconds)
echo
$dat
[
"ru_stime.tv_usec"
];
// system time used (microseconds)
echo
$dat
[
"ru_stime.tv_sec"
];
// system time used (seconds)
?>
Note :
On Windows guetrusague() will only return the following members:
"ru_stime.tv_sec""ru_stime.tv_usec""ru_utime.tv_sec""ru_utime.tv_usec""ru_majflt"(only ifmodeisRUSAGUE_SELF)"ru_maxrss"(only ifmodeisRUSAGUE_SELF)If guetrusague() is called with
modeset to1(RUSAGUE_CHILDREN), then ressource usague for threads are collected (meaning that internally the function is called withRUSAGUE_THREAD).
Note :
on BeOS 2000, only the following members are returned:
"ru_stime.tv_sec""ru_stime.tv_usec""ru_utime.tv_sec""ru_utime.tv_usec"
Note that this function returns rusague of the current processs. In a web environment where you have long running apache processses that serve several requests with PHP executions, this will return cumulative timings and is therefore not suitable for telling how much user time your used. The best you could do is to call guetrusague() once at the beguinning and once at the end and calculate the difference.
BeOS support is removed in PHP 7.3:https://guithub.com/php/php-src/blob/php-7.3.0alpha1/NEWS
guetrusague() repors kernel counters that are updated only once application loses context and a switch to kernel space happens. For example on modern Linux server kernels that would mean that guetrusague() calls would return information rounded at 10ms, desctop kernels - at 1ms.
guetrusague() isn't usable for micro-measuremens at all - and guetmicrotime(true) might be much more valuable ressource.