Difference between revisions of "Setting up xhprof on Moodle"

Jump to: navigation, search
(Configuring Moodle to use xhprof)
(Configuring Moodle to use xhprof)
Line 31: Line 31:
  
 
==Configuring Moodle to use xhprof==
 
==Configuring Moodle to use xhprof==
 +
Once the xhprof php extension is correctly installed you will find a new "Profiling" option available under Settings > Site administration > Development
 
[[Image:profilingOption.png|thumb|center|The profiling option is displayed when the php xhprof extension is installed]]
 
[[Image:profilingOption.png|thumb|center|The profiling option is displayed when the php xhprof extension is installed]]
 +
When you load the profiling settings page you are confronted with several options. In order to get xhprof up and running with minimal fuss you mearly need to check the "Enable profiling" box and set a path that you wish to be profiled. You can simply set this to a wildcard using the asterisk symbol ('''*''') while you are testing profiling. Afterwards you can come back and set this to a more restrictive setting once you know profiling is working.
 
[[Image:profilingSettings.png|frame|center|Enabling profiling and setting it to run on all pages via a wildcard]]
 
[[Image:profilingSettings.png|frame|center|Enabling profiling and setting it to run on all pages via a wildcard]]
 
[[Image:profilingRuns.png|frame|center|A profiling runs option can be seen after enabling profiling]]
 
[[Image:profilingRuns.png|frame|center|A profiling runs option can be seen after enabling profiling]]
[[Image:profilingOutput.png|thumb|center|Tabular profiling output produced by xhprof]]
+
[[Image:profilingOutput.png|thumb|right|Tabular profiling output produced by xhprof]]
[[Image:callgraph.png|thumb|center|An example call graph showing slow parts of the profiled run]]
+
[[Image:callgraph.png|thumb|right|An example call graph showing slow parts of the profiled run]]

Revision as of 10:48, 27 February 2012

The following instructions are for setting up xhprof for Moodle under a Ubuntu/Debian environment. The process should be similar for other linux enviroments, but will need some tweaking if you wish to do this under windows. Please update this document if you find any major problems.

Installing xhprof

mkdir ~/src/
cd ~/src/
wget http://pecl.php.net/get/xhprof-0.9.2.tgz
tar xvf xhprof-0.9.2.tgz
cd xhprof-0.9.2/extension/
phpize
./configure
make
sudo make install

Add the following to the apache version of you php.ini file

[xhprof]
extension=xhprof.so
xhprof.output_dir="/var/tmp/xhprof"

Restart Apache

sudo service apache2 retart

Create a file in your web root that makes a call to phpinfo(); and then view the result in your browser to make sure that xhprof is enabled in PHP. Checking the output of php -m would also work if you are sure that the command line version of PHP uses the same php.ini file as your web server.

Configuring Moodle to use xhprof

Once the xhprof php extension is correctly installed you will find a new "Profiling" option available under Settings > Site administration > Development

The profiling option is displayed when the php xhprof extension is installed

When you load the profiling settings page you are confronted with several options. In order to get xhprof up and running with minimal fuss you mearly need to check the "Enable profiling" box and set a path that you wish to be profiled. You can simply set this to a wildcard using the asterisk symbol (*) while you are testing profiling. Afterwards you can come back and set this to a more restrictive setting once you know profiling is working.

Enabling profiling and setting it to run on all pages via a wildcard
A profiling runs option can be seen after enabling profiling
Tabular profiling output produced by xhprof
An example call graph showing slow parts of the profiled run