if (count($ids) == 1) { $query['request_id'] = $ids[0]; unset($query['request_ids']); } else { if (count($ids) == 2) { $query['request_id'] = $ids[0]; $query['second_request_id'] = $ids[1]; unset($query['request_ids']); } else { ay_redirect(\AY\REDIRECT_REFERRER, 'Sorry, this feature is currently not implemented.'); $template = 'requests'; } } unset($ids); } \ay\redirect(url($template, $query)); } // $_GET['xhprof']['query'] is used throughout the code to filter data. NULL value will be ignored. // This is a convenience method to prevent repetitious variable presence checking. if (empty($_GET['xhprof']['query'])) { $_GET['xhprof']['query'] = NULL; } else { foreach ($_GET['xhprof']['query'] as $e) { if (is_array($e)) { throw new \Exception('Defining a filter with a multidimensional array is not supported.'); } } // ay_input() will look for the default input value in this globally accessible variable. $input = array('query' => $_GET['xhprof']['query']); if (!empty($_GET['xhprof']['query']['datetime_from']) && !validate_datetime($_GET['xhprof']['query']['datetime_from'])) { \ay\message('Invalid <mark>from</mark> date-time format.');
} $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'])) { \ay\redirect(\ay\REDIRECT_REFERRER, 'Cannot compare the two requests. The callstack does not match.'); } else { if ($request == $second_request) { \ay\redirect(\ay\REDIRECT_REFERRER, 'Cannot compare the request to itself.'); } } } $second_xhprof_obj = new Model($second_request); $second_aggregated_stack = $second_xhprof_obj->getAggregatedStack(); } require __DIR__ . '/form.inc.tpl.php'; require __DIR__ . '/pie.inc.tpl.php'; /** * @param string $name Metrics name. * @param string $group Inclusive|Exclusive. * @param array $a Present request metrics. * @param array $b Request to compare to. */ $fn_metrics_column = function ($name, $group, $a, $b = null) {
<?php namespace ay\xhprof; if (!isset($_GET['xhprof']['query']['request_id'], $_GET['xhprof']['query']['callee_id'])) { throw new \Exception('Missing required parameters.'); } $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); $aggregated_family = $xhprof_obj->getFamily($_GET['xhprof']['query']['callee_id']); if (!$aggregated_family) { throw new \Exception('Function is not in the callstack.'); } $table_row = function ($e) use($request) { $e['metrics'] = format_metrics($e['metrics']); $e['metrics']['inclusive'] = format_metrics($e['metrics']['inclusive']); $e['metrics']['exclusive'] = format_metrics($e['metrics']['exclusive']); $e['metrics']['relative'] = array(); foreach ($e['metrics']['inclusive'] as $name => $data) { $e['metrics']['relative'][$name] = format_number($request['total'][$name] == 0 ? 0 : $e['metrics']['inclusive'][$name]['raw'] * 100 / $request['total'][$name]); } ?> <tr<?php if ($e['internal']) { ?> class="internal"<?php } ?>