Exemple #1
0
/**
 * 批量创建目录
 *
 * @param string $path   文件夹路径
 * @param int    $mode   权限
 * @return bool
 */
function xhprof_mkdirs($path, $mode = 0777)
{
    if (!is_dir($path)) {
        xhprof_mkdirs(dirname($path), $mode);
        $error_level = error_reporting(0);
        $result = mkdir($path, $mode);
        error_reporting($error_level);
        return $result;
    }
    return true;
}
Exemple #2
0
 * @author Changhao Jiang (cjiang@facebook.com)
 */
// by default assume that xhprof_html & xhprof_lib directories
// are at the same level.
$GLOBALS['XHPROF_LIB_ROOT'] = dirname(__FILE__) . '/lib';
require_once $GLOBALS['XHPROF_LIB_ROOT'] . '/display/xhprof.php';
ini_set('max_execution_time', 100);
$params = array('run' => array(XHPROF_STRING_PARAM, ''), 'source' => array(XHPROF_STRING_PARAM, 'xhprof'), 'func' => array(XHPROF_STRING_PARAM, ''), 'type' => array(XHPROF_STRING_PARAM, 'png'), 'threshold' => array(XHPROF_FLOAT_PARAM, 0.01), 'critical' => array(XHPROF_BOOL_PARAM, true), 'run1' => array(XHPROF_STRING_PARAM, ''), 'run2' => array(XHPROF_STRING_PARAM, ''));
// pull values of these params, and create named globals for each param
xhprof_param_init($params);
// if invalid value specified for threshold, then use the default
if ($threshold < 0 || $threshold > 1) {
    $threshold = $params['threshold'][1];
}
// if invalid value specified for type, use the default
if (!array_key_exists($type, $xhprof_legal_image_types)) {
    $type = $params['type'][1];
    // default image type.
}
$log_path = __DIR__ . '/logs/' . date('Ymd') . '/';
if (!is_dir($log_path)) {
    xhprof_mkdirs($log_path);
}
$xhprof_runs_impl = new XHProfRuns_Default($log_path);
if (!empty($run)) {
    // single run call graph image generation
    xhprof_render_image($xhprof_runs_impl, $run, $type, $threshold, $func, $source, $critical);
} else {
    // diff report call graph image generation
    xhprof_render_diff_image($xhprof_runs_impl, $run1, $run2, $type, $threshold, $source);
}