walovaton Posted December 22, 2008 Share Posted December 22, 2008 Hello, In the same way you can track memory usage with memory_get_usage() and memory_get_peak_usage() is there a way to track cpu usage within a PHP script? Quote Link to comment Share on other sites More sharing options...
trq Posted December 22, 2008 Share Posted December 22, 2008 The only thing I could think of would be to grep ps, but your not going to get any information about how much cpu php is using f thats what your after. Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted December 22, 2008 Share Posted December 22, 2008 well php is a server side technology not client side Quote Link to comment Share on other sites More sharing options...
trq Posted December 22, 2008 Share Posted December 22, 2008 well php is a server side technology not client side I think we can safely assume the op is talking about cpu usage on the server. Quote Link to comment Share on other sites More sharing options...
walovaton Posted December 23, 2008 Author Share Posted December 23, 2008 Yes, I mean in the server side. It would be nice if PHP had some infrastructure to know how much CPU is using a given script. For example, PHP can measure execution time so it doesn't pass and established limit defined in php.ini. If I only could know that time it would be enough for me since that's the time it was actually using the CPU (which is not the same as the real elapsed time). The other ugly option is to execute some OS command to get the "TIME+" value shown in top at the beginning and at the end of the script and then calculate the difference. That value would be the actual CPU time in seconds used by the script. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.