xhprof的安装是很简单,记录下其在php函数中的使用代码别让自己给忘记了:
public static function startXhprof()
{
if (function_exists('xhprof_enable')) {
xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
}
}
public static function showXhprof()
{
if (function_exists('xhprof_enable') && function_exists('xhprof_disable')) {
self::$_xhprofData = xhprof_disable();
include_once "/data/cap/xhprof/xhprof_lib/utils/xhprof_lib.php"; //加载xhprof包
include_once "/data/cap/xhprof/xhprof_lib/utils/xhprof_runs.php";
$xhprof_runs = new XHProfRuns_Default();
$run_id = $xhprof_runs->save_run(self::$_xhprofData, "xhprof_info");
echo '
.' style="color:red;">查看xhprof状态
';
}
}
}