Beispiel #1
0
/**
 * Generate image from phprof run id and send it to client.
 *
 * @param object  $xhprof_runs_impl  An object that implements
 *                                   the iXHProfRuns interface
 * @param run_id, integer, the unique id for the phprof run, this is the
 *                primary key for phprof database table.
 * @param type, string, one of the supported image types. See also
 *              $xhprof_legal_image_types.
 * @param threshold, float, the threshold value [0,1). The functions in the
 *                   raw_data whose exclusive wall times ratio are below the
 *                   threshold will be filtered out and won't apprear in the
 *                   generated image.
 * @param func, string, the focus function.
 * @param bool, does this run correspond to a PHProfLive run or a dev run?
 * @author cjiang
 */
function xhprof_render_image($xhprof_runs_impl, $run_id, $type, $threshold, $func, $source, $critical_path)
{
    $content = xhprof_get_content_by_run($xhprof_runs_impl, $run_id, $type, $threshold, $func, $source, $critical_path);
    if (!$content) {
        print "Error: either we can not find profile data for run_id " . $run_id . " or the threshold " . $threshold . " is too small or you do not" . " have 'dot' image generation utility installed.";
        exit;
    }
    xhprof_generate_mime_header($type, strlen($content));
    echo $content;
}
/**
 * Generate image from phprof run id and send it to client.
 *
 * @param \Sugarcrm\XHProf\Viewer\Storage\StorageInterface  $storage  An object that implements
 *                                   the iXHProfRuns interface
 * @param run_id, integer, the unique id for the phprof run, this is the
 *                primary key for phprof database table.
 * @param type, string, one of the supported image types. See also
 *              $xhprof_legal_image_types.
 * @param threshold, float, the threshold value [0,1). The functions in the
 *                   raw_data whose exclusive wall times ratio are below the
 *                   threshold will be filtered out and won't apprear in the
 *                   generated image.
 * @param func, string, the focus function.
 * @param bool, does this run correspond to a PHProfLive run or a dev run?
 * @author cjiang
 */
function xhprof_render_image(\Sugarcrm\XHProf\Viewer\Storage\StorageInterface $storage, $run_id, $type, $threshold, $func, $source, $critical_path)
{
    $content = xhprof_get_content_by_run($storage, $run_id, $type, $threshold, $func, $source, $critical_path);
    if (!$content) {
        print "Error: either we can not find profile data for run_id " . $run_id . " or the threshold " . $threshold . " is too small or you do not" . " have 'dot' image generation utility installed (brew install graphviz).";
        exit;
    }
    xhprof_generate_mime_header($type, strlen($content));
    echo $content;
}