array(XHPROF_STRING_PARAM, ''), 'wts' => array(XHPROF_STRING_PARAM, ''), 'symbol' => array(XHPROF_STRING_PARAM, ''), 'sort' => array(XHPROF_STRING_PARAM, 'wt'), // wall time 'run1' => array(XHPROF_STRING_PARAM, ''), 'run2' => array(XHPROF_STRING_PARAM, ''), 'source' => array(XHPROF_STRING_PARAM, 'xhprof'), 'all' => array(XHPROF_UINT_PARAM, 0), ); // pull values of these params, and create named globals for each param xhprof_param_init($params); /* reset params to be a array of variable names to values by the end of this page, param should only contain values that need to be preserved for the next page. unset all unwanted keys in $params. */ foreach ($params as $k => $v) { $params[$k] = $$k; // unset key from params that are using default values. So URLs aren't // ridiculously long. if ($params[$k] == $v[1]) { unset($params[$k]); } } $vbar = ' class="vbar"'; $vwbar = ' class="vwbar"'; $vwlbar = ' class="vwlbar"'; $vbbar = ' class="vbbar"'; $vrbar = ' class="vrbar"'; $vgbar = ' class="vgbar"'; $xhprof_runs_impl = new XHProfRuns_Default(); $domainFilter = getFilter('domain_filter'); $serverFilter = getFilter('server_filter'); $domainsRS = $xhprof_runs_impl->getDistinct(array('column' => 'server name')); $domainFilterOptions = array("Все домены"); while ($row = XHProfRuns_Default::getNextAssoc($domainsRS)) { $domainFilterOptions[] = $row['server name']; } $serverRS = $xhprof_runs_impl->getDistinct(array('column' => 'server_id')); $serverFilterOptions = array("None"); while ($row = XHProfRuns_Default::getNextAssoc($serverRS)) { $serverFilterOptions[] = $row['server_id']; } $criteria = array(); if (!is_null($domainFilter)) { $criteria['server name'] = $domainFilter; } if (!is_null($serverFilter)) { $criteria['server_id'] = $serverFilter; } $_xh_header = ""; if(isset($_GET['run1']) || isset($_GET['run'])) { include ("../xhprof_lib/templates/header.phtml"); displayXHProfReport($xhprof_runs_impl, $params, $source, $run, $wts, $symbol, $sort, $run1, $run2); }elseif (isset($_GET['geturl'])) { $last = (isset($_GET['last'])) ? $_GET['last'] : 100; $last = (int) $last; $criteria['url'] = $_GET['geturl']; $criteria['limit'] = $last; $criteria['order by'] = 'timestamp'; $rs = $xhprof_runs_impl->getUrlStats($criteria); list($header, $body) = showChart($rs, true); $_xh_header .= $header; include ("../xhprof_lib/templates/header.phtml"); $rs = $xhprof_runs_impl->getRuns($criteria); include ("../xhprof_lib/templates/emptyBody.phtml"); $url = htmlentities($_GET['geturl'], ENT_QUOTES, "UTF-8"); displayRuns($rs, "Запросы к URL: $url"); }elseif (isset($_GET['getcurl'])) { $last = (isset($_GET['last'])) ? $_GET['last'] : 100; $last = (int) $last; $criteria['c_url'] = $_GET['getcurl']; $criteria['limit'] = $last; $criteria['order by'] = 'timestamp'; $rs = $xhprof_runs_impl->getUrlStats($criteria); list($header, $body) = showChart($rs, true); $_xh_header .= $header; include ("../xhprof_lib/templates/header.phtml"); $url = htmlentities($_GET['getcurl'], ENT_QUOTES, "UTF-8"); $rs = $xhprof_runs_impl->getRuns($criteria); include("../xhprof_lib/templates/emptyBody.phtml"); displayRuns($rs, "Запросы с упрощенным URL: $url"); }elseif (isset($_GET['getruns'])) { include ("../xhprof_lib/templates/header.phtml"); $days = (int) $_GET['days']; switch ($_GET['getruns']) { case "cpu": $load = "cpu"; $load_text = "CPU"; break; case "wt": $load = "wt"; $load_text = "времени выполнения"; break; case "pmu": $load = "pmu"; $load_text = "памяти"; break; } $criteria['order by'] = $load; $criteria['limit'] = "500"; $criteria['where'] = "date('now', '-$days day') <= `timestamp`"; $rs = $xhprof_runs_impl->getRuns($criteria); displayRuns($rs, "Запросы по максимальному значению $load_text"); }elseif(isset($_GET['hit'])) { include ("../xhprof_lib/templates/header.phtml"); $last = (isset($_GET['hit'])) ? $_GET['hit'] : 25; $last = (int) $last; $days = (isset($_GET['days'])) ? $_GET['days'] : 1; $days = (int) $days; if (isset($_GET['type']) && ($_GET['type'] === 'url' OR $_GET['type'] = 'curl')) { $type = $_GET['type']; }else { $type = 'url'; } $criteria['limit'] = $last; $criteria['days'] = $days; $criteria['type'] = $type; $resultSet = $xhprof_runs_impl->getHardHit($criteria); echo "
| URL | Посещений | Суммарное время выполнения | Среднее время выполнения |
|---|---|---|---|
| {$html['url']} | {$row['count']} | " . number_format($row['total_wall']) . " ms | " . number_format($row['avg_wall']) . " ms |