Script Garage

 

How do I find out which PHP scripts are slowing down my system?

I am a PHP newcomer and I'm writing a lot of scripts. Over this same time, I've seen sluggish performance from time to time with pages loading on my site. I thought it was my host at fault, but now I'm thinking maybe some of my practice scripts are running in the background without me knowing it, eating up bandwidth??? Is there a php command or function that I can use to find out what scripts of mine are currently running on the server side -- or is their some command I can give to stop any and all scripts of mine out there that may be caught in an infinite loop? Again, I'm thinking that some bad practice scripts of mine are slowing down my system performance because they're struggling to run in the background -- but I need to know how to check this. I've read a little about so-called "profilers" that seem to be for this purpose, but they all seem rather expensive and in any case, I haven't found any that say they'll work with a Mac. Thanks

Public Comments

  1. Assuming you're using a *nix system, the following shell commands executed on the server should help. "ps x" will display a list of processes that are currently running. If you see one that you'd like to kill, find its process ID number and then run "kill -9 id_number_here" Using the "top" command will display more detailed information about the processes running on the system. You can sort the list by pressing "m" to sort by % of memory usage, or "c" to sort by % of CPU usage. To exit top, press "q".
Powered by Yahoo! Answers