分层PHP性能分析工具--xhprof

纵然是瞬间 提交于 2020-03-30 21:20:39

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 '<br/><center><a target="_blank" href="'.Config::$xhprofDomain.'/index.php?run=' . $run_id . '&source=xhprof_info"'
                .' style="color:red;">查看xhprof状态</a></center><br />';
        }
    }
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!