- Install : Xdebug
Can be done by install then entering the following : /etc/php/7.1/fpm/php.ini:
zend_extension = /usr/lib/php/20160303/xdebug.so xdebug.profiler_enable = 0 xdebug.profiler_output_name = cachegrind.out.%t xdebug.profiler_enable_trigger = 1 xdebug.profiler_output_dir = /tmp xdebug.profiler_enable_trigger_value = "<super secret key>"
In order, the configuration goes as follows: load the module, disable profiling be default, set the filename, enable triggering via GET/POST parameter, output in /tmp and only profile when given the key.
Restart php-fpm and you should be good to go.
2) Use the ?XDEBUG_PROFILE=<super secret key> appended to any page you want to debug and the debug file will be put in /tmp.
3) Open the debug file using something like : https://github.com/jokkedk/webgrind For Analysis specifically for reducing
Invocation Count is how many times that function was called. A simple tip for reducing this is to pull out any repetitive function calls from a for-loop into a single variable.
Total Self Cost is the total percentage or time that the function is responsible for. You can improve this by reducing code complexity, using built-in native functions or removing unused variables.