Skip to content
An xhprof module for SilverStripe
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

#Heyday xhprof

This module provides a SilverStripe-centric wrapper for the pecl package xhprof and the xhprof gui.

For a version compatible with SilverStripe 2.4 see the 1.0 branch.


This project is licensed under an MIT license which can be found at silverstripe-xhprof/LICENSE


You will require xhprof installed in php to use silverstripe-xhprof. In order to create call graphs through the xhprof gui you will also need Graphviz.


To install drop the silverstripe-xhprof directory into your SilverStripe root and run /dev/build?flush=1.

##How to use

You can use silverstripe-xhprof in two ways. As a global profiler or as a profiler of specific segments of code. Please note, you can't do both global profiling and local profiling in the same request.

###Global Profiling

####With Sake


./sake xhprof/enable


./sake xhprof/disable

####Without sake (you need to have ADMIN privedges)





Enabling global profiling edits your .htaccess file by adding two lines of code to the beginning, but silverstripe-xhprof makes a backup of your .htaccess which can be found in silverstripe-xhprof/code/GlobalProfile/backup/.

When you disable global profiling your .htaccess file will be restored from the backup.

###Local Profiling

To profile a specific segment of code you need to first ensure global profiling is disabled, and then you need to set up the requisite HeydayXhprof::start() and HeydayXhprof::end() calls.

HeydayXhprof::start('Potentially Troublesome Code');

//Code to profile


##Viewing saved profiles

For each profile made, there is a corresponding database record (HeydayXhprofRun) created. These database records store information about the request (url, query string etc) that the profiling occured on, and also the identifier to the profile.

To view profiles saved go to:


All global profiles are saved under the App name of Global.


There are a couple of configuation options available when profiling. Global config options can be set in a php file located at:


When global profiling is enabled, this file (if it exists) is included before any SilverStripe code is included.

###Limiting global profiling by probability

To limit requests profiled you can use a probability. This useful for profiling on live server under load.


This example would make the probability of a profile being made 2 in 3


This example would make the probability of a profile being made 1 in 1000

###Limiting local profiling by probability

if (HeydayXhprof::testProbability(1/100)) {

	HeydayXhprof::start('Potentially Troublesome Code');


//Code to profile

if (HeydayXhprof::isStarted()) {



###Excluding urls by partial matching (specifically strpos)

To exclude certain urls:


##Unit Testing

If you have phpunit installed you can run silverstripe-xhprof's unit tests to see if everything is functioning correctly.

###Running the unit tests

From the command line:

./sake dev/tests/module/silverstripe-xhprof

From your browser:



###Code guidelines

This project follows the standards defined in:

You can’t perform that action at this time.