{"id":3191,"date":"2018-01-19T22:01:44","date_gmt":"2018-01-19T22:01:44","guid":{"rendered":"http:\/\/pariswells.com\/blog\/?p=3191"},"modified":"2018-04-20T13:18:42","modified_gmt":"2018-04-20T13:18:42","slug":"debugging-and-slowness-with-php","status":"publish","type":"post","link":"https:\/\/pariswells.com\/blog\/code\/debugging-and-slowness-with-php","title":{"rendered":"Debugging and Slowness with Php"},"content":{"rendered":"<ol><li>Install :\u00a0<a href=\"https:\/\/xdebug.org\/\">Xdebug<\/a>\u00a0<\/li><\/ol><p>Can be done by install then entering the following :\u00a0\u00a0<strong>\/etc\/php\/7.1\/fpm\/php.ini<\/strong>:<\/p><div class=\"highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>zend_extension = \/usr\/lib\/php\/20160303\/xdebug.so\r\nxdebug.profiler_enable = 0\r\nxdebug.profiler_output_name = cachegrind.out.%t\r\nxdebug.profiler_enable_trigger = 1\r\nxdebug.profiler_output_dir = \/tmp\r\nxdebug.profiler_enable_trigger_value = \"&lt;super secret key&gt;\"\r\n<\/code><\/pre><\/div><\/div><p>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.<\/p><p>Restart php-fpm and you should be good to go.<\/p><p>2) Use the\u00a0?XDEBUG_PROFILE=&lt;super secret key&gt; appended to any page you want to debug and the debug file will be put in\u00a0\/tmp.<\/p><p>3) Open the debug file using something like :\u00a0<a href=\"https:\/\/github.com\/jokkedk\/webgrind\">https:\/\/github.com\/jokkedk\/webgrind<\/a>\u00a0 For Analysis specifically for reducing\u00a0<\/p><p><strong>Invocation Count<\/strong>\u00a0is 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.<\/p><p>\u00a0<strong>Total Self Cost is<\/strong>\u00a0the 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.<\/p>","protected":false},"excerpt":{"rendered":"<p>Install :\u00a0Xdebug\u00a0Can be done by install then entering the following :\u00a0\u00a0\/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 = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[320],"tags":[1391,698,2397,2396,2398],"class_list":["post-3191","post","type-post","status-publish","format-standard","hentry","category-code","tag-debug","tag-php","tag-profile","tag-slowness","tag-xdebug"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/3191","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/comments?post=3191"}],"version-history":[{"count":1,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/3191\/revisions"}],"predecessor-version":[{"id":3192,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/3191\/revisions\/3192"}],"wp:attachment":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/media?parent=3191"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/categories?post=3191"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/tags?post=3191"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}