1

Lately I have gotten myself into a predicament. My system started consuming too much CPU and it turns out that along with a few SQL queries (that got logged in MySQL slow query log), there is also a number of PHP scripts that take too long to execute.

Question is: is there a way to determine the execution time of let's say 2000+ PHP scripts (how long it took to execute) without having to insert a snippet of code inside each and every one of them?

I was reading up on profiling but it does not seem the kind of thing I need. Thanks.

McJohnson
  • 313
  • 1
  • 11
  • I do think that profiling is what you need here. There are lots of options for PHPprofiling, most are free. You might want to try xdebug: http://xdebug.org/docs/profiler which works well with the latest version of PHP and has a very nice GUI. Note that no custom code needs to be inserted to profile so obtaining the info you need is quite simple. – shelbypereira Dec 24 '15 at 21:26
  • If possible you could do a `time();` and write that to a file in your first script then a `time();` in your last script and write that to the same file again. Then calculate what the difference is between the 2. – Santy Dec 24 '15 at 21:27
  • I agree with shev72. Just because a script is taking too much time does not mean that it is using a lot of CPU, e.g. it could be doing some unexpected blocking. Also, figure out the smallest workload you can run and use that for profiling. – Taylor Kidd Jan 02 '16 at 21:01

0 Answers0