Example #1
0
namespace ay\xhprof;

/**
 * @var $xhprof_data_obj data
 */
if (empty($_GET['xhprof']['query']['request_id'])) {
    throw new \Exception('Request data can be accessed only through the ID.');
}
$request = $xhprof_data_obj->get($_GET['xhprof']['query']['request_id']);
if (!$request) {
    \ay\redirect(\ay\REDIRECT_REFERRER, 'Request data not found.');
}
$xhprof_obj = new Model($request);
if (!empty($_GET['xhprof']['callgraph'])) {
    $xhprof_callgraph = new Callgraph($request);
    $callstack = $xhprof_obj->assignUID();
    $dot_script = $xhprof_callgraph->dot($callstack);
    $xhprof_callgraph->graph($dot_script);
    // Further script execution is terminated.
}
$aggregated_stack = $xhprof_obj->getAggregatedStack();
if (isset($_GET['xhprof']['query']['second_request_id'])) {
    $second_request = $xhprof_data_obj->get($_GET['xhprof']['query']['second_request_id']);
    if (!$second_request) {
        \ay\redirect(\ay\REDIRECT_REFERRER, 'Second request data not found.');
    } else {
        if (array_map(function ($e) {
            return $e['callee_id'];
        }, $request['callstack']) !== array_map(function ($e) {
            return $e['callee_id'];
        }, $second_request['callstack'])) {