/**
 * Generate image content from phprof run id.
 *
 * @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.
 * @returns, string, the DOT script to generate image.
 *
 * @author cjiang
 */
function xhprof_get_content_by_run($xhprof_runs_impl, $run_id, $type, $threshold, $func, $source, $critical_path)
{
    if (!$run_id) {
        return "";
    }
    $raw_data = $xhprof_runs_impl->get_run($run_id, $source, $description);
    if (!$raw_data) {
        watchdog('XHProf', 'Raw data is empty', array(), WATCHDOG_WARNING);
        return "";
    }
    $script = xhprof_generate_dot_script($raw_data, $threshold, $source, $description, $func, $critical_path);
    $content = xhprof_generate_image_by_dot($script, $type);
    return $content;
}
Example #2
0
/**
 * Generate image content from phprof run id.
 *
 * @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.
 * @returns, string, the DOT script to generate image.
 *
 * @author cjiang
 */
function xhprof_get_content_by_run($xhprof_runs_impl, $run_id, $type, $threshold, $func, $source, $critical_path)
{
    if (!$run_id) {
        return "";
    }
    $raw_data = $xhprof_runs_impl->get_run($run_id, $source, $description);
    if (!$raw_data) {
        xhprof_error("Raw data is empty");
        return "";
    }
    $script = xhprof_generate_dot_script($raw_data, $threshold, $source, $description, $func, $critical_path);
    $content = xhprof_generate_image_by_dot($script, $type);
    return $content;
}
/**
 * Generate image content from phprof run id.
 *
 * @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.
 * @returns, string, the DOT script to generate image.
 *
 * @author cjiang
 */
function xhprof_get_content_by_run(\Sugarcrm\XHProf\Viewer\Storage\StorageInterface $storage, $run_id, $type, $threshold, $func, $source, $critical_path)
{
    if (!$run_id) {
        return "";
    }
    $raw_data = $storage->getRunXHProfData($run_id);
    if (!$raw_data) {
        xhprof_error("Raw data is empty");
        return "";
    }
    $script = xhprof_generate_dot_script($raw_data, $threshold, $source, $run_id, $func, $critical_path);
    $content = xhprof_generate_image_by_dot($script, $type);
    return $content;
}