예제 #1
0
        unset($params[$k]);
    }
}
////echo "<html>";
////echo "<head><title>XHProf: Hierarchical Profiler Report</title>";
////xhprof_include_js_css();
////echo "</head>";
////echo "<body>";
$vbar = ' class="vbar"';
$vwbar = ' class="vwbar"';
$vwlbar = ' class="vwlbar"';
$vbbar = ' class="vbbar"';
$vrbar = ' class="vrbar"';
$vgbar = ' class="vgbar"';
$xhprof_runs_impl = new XHProfRuns_Default(eZXHProfLogger::logDir());
displayXHProfReport($xhprof_runs_impl, $params, $GLOBALS['source'], $GLOBALS['run'], $GLOBALS['wts'], $GLOBALS['symbol'], $GLOBALS['sort'], $GLOBALS['run1'], $GLOBALS['run2']);
////echo "</body>";
////echo "</html>";
$body = ob_get_clean();
$info = false;
$infoFile = eZXHProfLogger::logDir() . "/{$GLOBALS['run']}.info";
if (file_exists($infoFile)) {
    $info = eZPerfLoggerApacheLogger::parseLogLine(file_get_contents($infoFile));
}
$tpl = eZTemplate::factory();
$tpl->setVariable('body', $body);
$tpl->setVariable('error', $error);
$tpl->setVariable('run', $GLOBALS['run']);
$tpl->setVariable('info', $info);
$Result['content'] = $tpl->fetch('design:xhprof/view.tpl');
$Result['path'] = array(array('text' => 'XHProf', 'url' => 'xhprof/list'), array('text' => 'Run: ' . $GLOBALS['run'], 'url' => 'xhprof/view?run=' . $GLOBALS['run']));
예제 #2
0
 /**
  * Returns list of saved runs
  * @return array
  *     'list' => array( '<runkey>' => array( 'time' => <run timestamp>, ... ) )
  *     'count' => total available runs
  */
 public static function savedRuns($offset = 0, $limit = 0)
 {
     $runsList = array();
     $count = 0;
     if (!is_dir(self::logDir())) {
         return array($runsList, $count);
     }
     // nb: PHP_SCANDIR_SORT_DESCENDING === 1, but only defined since php 5.4.0
     foreach (scandir(self::logDir(), 1) as $file) {
         $fullfile = self::logDir() . "/" . $file;
         if (is_file($fullfile) && substr($file, -7) == '.xhprof') {
             $count++;
             if ($count >= $offset && ($limit <= 0 || count($runsList) <= $limit)) {
                 $run = substr($file, 0, -7);
                 $runsList[$run] = array('time' => filemtime($fullfile));
                 if (is_file($infoFile = self::logDir() . "/{$run}.info")) {
                     if (is_array($info = eZPerfLoggerApacheLogger::parseLogLine(file_get_contents($infoFile)))) {
                         $runsList[$run] = $info;
                     }
                 }
             }
         }
     }
     return array($runsList, $count);
 }