Slow PHP script - automatic debugging and diagnostics?

How can I find out if a PHP script works badly and works very slowly when hundreds of users work every second, and even better, is there any tool that could tell me approximately which part of the code is slowing me down? ...

I don’t want to publish the code here (mainly because this question refers to something else and because it is a waste of space) and preferably never publish it anywhere because it is actually a mess! ... mess which I understand and yes, I encoded it, but it's still a mess that offends anyone who tries to understand it ... so if you have any creative ideas, please let me know!

Hurrah!

(thank you for the answers!)

+6
source share
3 answers

Enable XDebug profiling and send the resulting files through WinCacheGrind (Windows) or KCacheGrind (Linux).

This will allow you to see which functions were called most often and where time is wasted. Learning to use XDebug is a must for any serious PHP developer.

Here is a seemingly good guide to getting started with XDebug profiling .

+8
source

You will need two tools

  • profiler (Google it)

I use this when working:

http://www.nusphere.com/products/php_profiler.htm (commercial)

  • load tester

Check this site for more information:

http://performance-testing.org/content/performance-testing-tools

+3
source

I would recommend using the PHP profiler. Xdebug , which is both a PHP debugger and a profiler. There are other debuggers, for example. Zend Debugger.

You may also need a special tool to analyze profiling results. I used WinCacheGrind on Windows and KCachegrind on Linux.

A profiling report shows a ton of useful information, for example. which lines of source code were called how many times and which functions took up most of the execution time.

+2
source

Source: https://habr.com/ru/post/891345/


All Articles