Skip to content
This repository has been archived by the owner on Feb 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #603 from geerlingguy/blackfire
Browse files Browse the repository at this point in the history
Fixes #526: Add Blackfire.io support to Drupal VM.
  • Loading branch information
geerlingguy committed May 11, 2016
2 parents 4e0b4a0 + 3ce2be1 commit eb8e0b4
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 19 deletions.
50 changes: 50 additions & 0 deletions docs/extras/profile-code.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
You can profile your code using one of the supported profiling tools included in Drupal VM.

As a prerequisite, you need to make sure the profiler you'd like to use is listed (and not commented out) in `installed_extras` inside `config.yml` (So the appropriate software is installed on Drupal VM).

**Note**: You should only enable one code profiler at a time—e.g. when using Blackfire, disable XHProf and XDebug.

## Blackfire

[Blackfire.io](https://blackfire.io/) is a service that allows code profiling to be stored and analyzed via an online profile on the Blackfire.io website.

It doesn't require any additional Drupal modules to use, but once you've made sure `blackfire` is in the list of `installed_extras` in `config.yml` (and Drupal VM has been provisioned), you need to log into Drupal VM and [run the setup steps outlined on the Blackfire Ansible role's README](https://github.com/geerlingguy/ansible-role-blackfire#requirements).

Once you've configured your environment for your own Blackfire account, you can profile a request with Blackfire by running something like the following example (within Drupal VM, after logging in with `vagrant ssh`):

```
$ blackfire curl http://drupalvm.dev/
Profiling: [########################################] 10/10
Blackfire cURL completed
Graph URL https://blackfire.io/profiles/[UUID]/graph
Wall Time 151ms
CPU Time 130ms
I/O Time 20.9ms
Memory 1.5MB
Network n/a n/a -
SQL n/a -
```

## XHProf

[XHProf](http://xhprof.io/) allows easy code profiling and can be used in many different ways. Ensure `xhprof` is in the list of `installed_extras` inside `config.yml`.

### XHProf module

The easiest way to use XHProf to profile your PHP code on a Drupal site is to install the [XHProf](https://www.drupal.org/project/xhprof) module, then in XHProf's configuration (at `/admin/config/development/xhprof`), check the 'Enable profiling of page views and drush requests' checkbox.

The XHProf module doesn't include built-in support for callgraphs, but there's an issue to [add callgraph support](https://www.drupal.org/node/1470740).

You can view callgraphs (and a listing of all stored runs) using Drupal VM's own XHProf installation by visiting `http://xhprof.drupalvm.dev/` and clicking on the relevant run, then clicking the "[View Full Callgraph]" link.

### Devel module (deprecated)

The Devel module also *used* to provide XHProf configuration, and setting the options below would allow Devel's XHProf integration to work correctly with Drupal VM's XHProf installation:

- **xhprof directory**: `/usr/share/php`
- **XHProf URL**: `http://xhprof.drupalvm.dev` (assuming this domain is configured in `apache_vhosts` inside `config.yml`)

## XDebug

[XDebug](https://xdebug.org/) is a debugger and profiler for PHP. While most people use it only for debugging purposes, you can also use it for profiling. It's not as commonly used for profiling as either Blackfire or XHProf, but it works!
18 changes: 0 additions & 18 deletions docs/extras/xhprof.md

This file was deleted.

1 change: 1 addition & 0 deletions example.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ mysql_users:
# to install *any* extras, make set this value to an empty set, e.g. `[]`.
installed_extras:
- adminer
# - blackfire
- drupalconsole
- mailhog
- memcached
Expand Down
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pages:
- 'Use Node.js and NPM': 'extras/nodejs.md'
- 'Use SSL vhosts with Apache': 'extras/ssl.md'
- 'View Logs with Pimp my Log': 'extras/pimpmylog.md'
- 'Profile Code with XHProf': 'extras/xhprof.md'
- 'Profile Code - XHProf, Blackfire, Xdebug': 'extras/profile-code.md'
- 'Debug Code with XDebug': 'extras/xdebug.md'
- 'Catch Emails with MailHog': 'extras/mailhog.md'
- 'Test with Behat and Selenium': 'extras/behat.md'
Expand Down
1 change: 1 addition & 0 deletions provisioning/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
- { role: geerlingguy.php-memcached, when: '"memcached" in installed_extras' }
- { role: geerlingguy.php-xdebug, when: '"xdebug" in installed_extras' }
- { role: geerlingguy.php-xhprof, when: '"xhprof" in installed_extras' }
- { role: geerlingguy.blackfire, when: '"blackfire" in installed_extras' }
- { role: geerlingguy.adminer, when: '"adminer" in installed_extras' }
- { role: geerlingguy.pimpmylog, when: '"pimpmylog" in installed_extras' }
- { role: geerlingguy.daemonize, when: '"mailhog" in installed_extras' }
Expand Down
1 change: 1 addition & 0 deletions provisioning/requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- src: geerlingguy.adminer
- src: geerlingguy.apache
- src: geerlingguy.apache-php-fpm
- src: geerlingguy.blackfire
- src: geerlingguy.composer
- src: geerlingguy.daemonize
- src: geerlingguy.drupal-console
Expand Down

0 comments on commit eb8e0b4

Please sign in to comment.