Git Product home page Git Product logo

silverstripe-xhprof's Introduction

#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.

##License

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

##Requirements

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.

##Installation

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

Enable:

./sake xhprof/enable

Disable:

./sake xhprof/disable

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

Enable:

http://localhost/xhprof/enable

Disable:

http://localhost/xhprof/disable

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.

<?php
HeydayXhprof::start('Potentially Troublesome Code');

//Code to profile

HeydayXhprof::end();

##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:

http://localhost/admin/xhprof/

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

##Configuation

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

./mysite/_config_xhprof.php

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.

<?php
HeydayXhprof::setProbability(2/3);

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

<?php
HeydayXhprof::setProbability(1/1000);

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

###Limiting local profiling by probability

<?php
if (HeydayXhprof::testProbability(1/100)) {

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

}

//Code to profile

if (HeydayXhprof::isStarted()) {

	HeydayXhprof::end();

}

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

To exclude certain urls:

<?php
HeydayXhprof::addExclusions(array(
	'/admin/xhprof/',
	'/Security/ping'
));

##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:

http://localhost/dev/tests/module/silverstripe-xhprof

##Contributing

###Code guidelines

This project follows the standards defined in:

silverstripe-xhprof's People

Contributors

camspiers avatar frazerfindlater avatar

Watchers

James Cloos avatar helpfulrobot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.