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? Link to comment https://forums.phpfreaks.com/topic/138050-how-to-track-cpu-usage/ 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. Link to comment https://forums.phpfreaks.com/topic/138050-how-to-track-cpu-usage/#findComment-721672 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 Link to comment https://forums.phpfreaks.com/topic/138050-how-to-track-cpu-usage/#findComment-721683 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. Link to comment https://forums.phpfreaks.com/topic/138050-how-to-track-cpu-usage/#findComment-721775 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. Link to comment https://forums.phpfreaks.com/topic/138050-how-to-track-cpu-usage/#findComment-722287 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.