The author of the article mentioned in the previous post says "Once I got a negative value for both times - I have absolutely no clue how that can happen.". This is because time in microseconds is not padded with zeros from the left, therefore, you cannot concatenate the two numbers. Instead, you should normalize the values and then add them up:
$dat["ru_utime.tv_sec"]*1e6+$dat["ru_utime.tv_usec"];
getrusage
(PHP 4, PHP 5)
getrusage — Získat informace o současném využití zdrojů
Popis
array getrusage ( [int $who] )Toto je rozhraní ke to getrusage(2). Vrátí asociativní pole obsahující všechna data vrácená systémovým voláním. Pokud je who 1, getrusage se zavolá s RUSAGE_CHILDREN.
Všechny položky jsou přístupné skrze svá dokumentovaná jména.
Příklad 1563. Getrusage příklad
$dat = getrusage();
echo $dat["ru_nswap"]; # počet swapů
echo $dat["ru_majflt"]; # počet page faultů
echo $dat["ru_utime.tv_sec"]; # využitý uživatelský čas (sekundy)
echo $dat["ru_utime.tv_usec"]; # využitý uživatelský čas (mikrosekundy)
Další detaily viz man stránka getrusage(2) na vašem systému.
getrusage
php at lavrenko dot pp dot ru
19-Oct-2005 04:21
19-Oct-2005 04:21
ng4rrjanbiah at rediffmail dot com
17-Nov-2004 02:51
17-Nov-2004 02:51
Here is a nice comment on benchmarking PHP codes using getrusage function http://blog.rompe.org/node/85
HTH,
R. Rajesh Jeba Anbiah
