Bookmark and Share

Thursday, March 29, 2018

Wordpress php performance analysis

If you need to check the performance of your Wordpress installation (or any PHP application) you can use the awesome XDEBUG Extension for PHP.

Steps to follow:

  • On the web server open a command/shell and execute
    php -i > c:\phpinfo.txt
  • Copy the output fron the phpinfo.txt
  • Connect to https://xdebug.org/wizard.php
  • Copy the phpinfo and analyze it using the wizard:
    image
  • Click “Analyze”, they will give you installation instructions:
    image

Here are the steps I followed on windows:

  • On windows download the http://xdebug.org/files/php_xdebug-2.6.0-7.1-vc14-nts-x86_64.dll  dll
  • Copy it in your PHP extension PATH , example : C:\Program Files\PHP\v7.1\ext
  • Edit the php.ini file, i.e : C:\Program Files\PHP\v7.1\php.ini
  • Add on the top these commands:
    xdebug.profiler_enable = 1
    xdebug.profiler_enable_trigger = 0
    xdebug.profiler_output_dir = "C:/Temp/"
  • Be sure the C:\Temp folder exists, the logs will be copied here
  • Add also this line :
    zend_extension = "c:\Program Files\PHP\v7.1\ext\php_xdebug-2.6.0-7.1-vc14-nts-x86_64.dll"

After you followed the installation instructions here is the analysis part:

  • Install this tool : https://sourceforge.net/projects/qcachegrindwin/, it’s the log viewer
  • Reload your page, the c:\Temp folder should start to be populated with “cachegrind.out” files
  • Note that the page will be slower…. so don’t forget to comment all commands after your analysis finishes.
  • Open QCacheGrind
  • Open the log file
  • Activate the Callee Map on the right:
    image
  • It seems I have a problem related to the “sqli_real_connect”….
  • Investigate and fix the problem (in my case I used the db name localhost instead of 127.0.0.1  https://stackoverflow.com/questions/13439817/why-is-my-mysqli-connection-so-slow)
  • Analyze again….
    image
  • Well, the sqli_real_connect problem seems fixed.

Hope it helps!

    No comments:

    Post a Comment