dotherightthing / wpdtrt-plugin-boilerplate

Boilerplate for WordPress plugin development. Formerly named wpdtrt-plugin.
2 stars 2 forks source link

Performance testing (Blackfire.io) #149

Open dotherightthing opened 6 years ago

dotherightthing commented 6 years ago

My local WP LAMP environment is slow to load. Are my plugins contributing to this?

dotherightthing commented 6 years ago

A quick Google for 'bottlenecks WordPress' led me to this post which mentions Blackfire. I've signed up for a free 'Hack' account and followed the installation instructions...

screen shot 2018-07-28 at 9 51 57 pm

dotherightthing commented 6 years ago

From the installation:

Blackfire: Installing the PHP Probe

Non Homebrew-PHP users (MacOS X native PHP, MAMP, MAMP Pro, etc)

When using a PHP different than the one shipped with MacOS X, please ensure the php binary from your PATH is the one you want to use Blackfire on. For example if you are using MAMP, when you run which php, the path returned should mention MAMP.

  1. Locate the PHP Binary referenced in my PATH
which php

/usr/bin/php

  1. Locate the MAMP PHP Binary

http://localhost/MAMP/index.php?language=English&page=phpinfo

Configuration File (php.ini) Path /Applications/MAMP/bin/php/php5.6.30/conf

  1. Change the PATH to use the MAMP Path

https://stackoverflow.com/questions/4145667/how-to-override-the-path-of-php-to-use-the-mamp-path

 sudo nano ~/.bash_profile      

export PATH="/Applications/MAMP/Library/bin:$PATH"

export MAMP_PHP=/Applications/MAMP/bin/php/php5.6.30/bin
export PATH="$MAMP_PHP:$PATH"
  1. Restart Terminal

  2. Test the changes

which php

/Applications/MAMP/bin/php/php5.6.30/bin/php


Execute the command below replacing 56 by the installed PHP version and follow the instructions in the command output:

brew install blackfire-php56 --without-homebrew-php

Versions are listed here: https://github.com/blackfireio/homebrew-blackfire/tree/master/Formula

brew install blackfire-php56 --without-homebrew-php

==> Caveats To finish installing blackfire for PHP 5.6:

  • Add the following lines to php.ini presented by php --ini:

[blackfire] extension="/usr/local/opt/blackfire-php56/blackfire.so" blackfire.agent_socket = unix:///usr/local/var/run/blackfire-agent.sock blackfire.agent_timeout = 0.25 ;blackfire.log_level = 3 ;blackfire.log_file = /tmp/blackfire.log ;blackfire.server_id = ;blackfire.server_token =

php --ini                                                                                                                                               

Configuration File (php.ini) Path: /Applications/MAMP/bin/php/php5.6.30/conf Loaded Configuration File: /Applications/MAMP/bin/php/php5.6.30/conf/php.ini Scan for additional .ini files in: (none)

MAMP > File > Edit Template > PHP (php.ini) > 5.6.30

  • Validate installation via one of the following methods:
    • Restart your webserver or PHP-fpm.

Restarted MAMP

  • Write a PHP page that calls "phpinfo();" ... and look for the info on the "blackfire" module.
php -i | grep blackfire

No info on the "blackfire" module.

Using PHP from the command line:

  • Run php --ri blackfire
  • If the "blackfire" configuration is displayed, you have been successful!
php --ri blackfire

Extension 'blackfire' not present.

Tried again, moving the blackfire block:

> to here
; DONT REMOVE: MAMP PRO php5.6.30.ini template compatibility version: 10
> from here

Restarted MAMP (had to force quit Apache), still no dice.

Will try again after a restart.

dotherightthing commented 6 years ago

Extension does exist at the specified path:

extension="/usr/local/opt/blackfire-php56/blackfire.so"

dotherightthing commented 6 years ago

;blackfire.log_level = 3 ;blackfire.log_file = /tmp/blackfire.log ;blackfire.server_id = ;blackfire.server_token =

Uncommented these 4 lines, adding my server ID and token as per https://stackoverflow.com/questions/30202276/setting-up-blackfire-io-on-a-mamp-pro-installation-mac-osx#30249897, this didn't help

dotherightthing commented 6 years ago

Restarted Macbook, started MAMP

which php

/Applications/MAMP/bin/php/php5.6.30/bin/php

php --ini

Configuration File (php.ini) Path: /Applications/MAMP/bin/php/php5.6.30/conf Loaded Configuration File: /Applications/MAMP/bin/php/php5.6.30/conf/php.ini Scan for additional .ini files in: (none) Additional .ini files parsed: (none)

find /usr/local/opt/blackfire-php56/blackfire.so

/usr/local/opt/blackfire-php56/blackfire.so

MAMP > File > Edit Template > PHP (php.ini) > 5.6.30

screen shot 2018-07-28 at 10 16 00 pm

php --ri blackfire

Extension 'blackfire' not present.

dotherightthing commented 6 years ago

Fixing #150 changed the Query Monitor status from red to orange.

dotherightthing commented 5 years ago

To retry with PHP 7