getrusage

getrusage

At an operating system level it’s easy to see the number of page faults, swaps, flushes etc for your computer, but how do you accomplish it through PHP? The getrusage function can be used to return an associative array containg details of system level calls. Its signature looks like this:

array getrusage ( [int who])

This function only works on Linux. Here’s some sample code:

<?php

$usage_stats = getrusage();

// Print the entire contents of the $usage_stats array
print_r($usage_stats);

// Show some individual parts of the $usage_stats array
echo “Number of page faults: ” . $usage_stats[”ru_majflt”];
echo “User time used in seconds: ” . $usage_stats[”ru_utime.tv_sec”];

?>

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.