Performance analysis of PHP code.
You can use Xdbug to analyze.
But a better choice is Facebook's performance analysis tool, Xhprof.
It can be graphically structured. The premise is that you installed the GD library, you may also encounter some minor problems. I remember to update the Linux image Library.
Install xhprof extension: pecl install xhprof.
<?php
/**
*
*
* Beck Confidential
* Copyright (c) 2013, Beck Corp. <BECK.BI>
* All rights reserved.
*
* PHP version 5
*
* @category Aug
* @package package_name
* @author Beck
* @date 2013-8-13
* @license
* @link
*
*/
class Xhprof
{
protected $flags = 0;
Protected $options = Array ();
Protected $xhprofData = Array ();
/**
* Configure your xhprof you can see a description of the application on the website of PHP
* @param unknown $config
* @throws extensionnotfoundexception
*/
Public function __construct ($config = Array ())
{
if (!extension_loaded (' xhprof ')) {
throw new Extensionnotfoundexception (
' Configuration error! Make sure your have Xhprof installed correctly.
please refer http://www.php.net/manual/en/xhprof.examples.php for detail. '
);
}
if (!empty ($config [' flags '])) {
$this->flags = (int) $config [' flags '];
}
if (!empty ($config [' Options '])] {
$this->options = $config [' Options '];
}
}
/**
* Open Debugging
*/
Public function enable ()
{
xhprof_enable ($this->flags, $this->options);
}
Public function Disable ()
{
$this->xhprofdata = xhprof_disable ();
}
/**
* Display debug Results
* You may need to configure a apache/ nginx Virtual host
*/
Public function Show ()
{
$this->disable ();
include_once "xhprof_lib/utils/xhprof_lib.php";
include_once "xhprof_lib/utils/xhprof_runs.php";
$xhprof _runs = new Xhprofruns_default ();
$run _id = $xhprof _runs->save_run ($this->xhprofdata, "xhprof_testing");
echo "<a href= ' http://pear.kang.com/xhprof_html/index.php?run={$run _id}&source=xhprof_testing ' target= ' _blank ' >see xhprof result</a> ';
}
}