Пример #1
0
 function __construct()
 {
     $this->files = $this->getFiles(Config::xdebugOutputFormat(), Config::xdebugOutputDir());
     uasort($this->files, array($this, 'compare'));
 }
Пример #2
0
 private static function doFunctionList()
 {
     $dataFile = @$_GET['dataFile'];
     $costFormat = isset($_GET['costFormat']) ? $_GET['costFormat'] : Config::$defaultCostformat;
     if ($dataFile === '0') {
         $file = FileHandler::instance()->getTraceList();
         $dataFile = $file[0]['filename'];
     }
     $reader = new WGEntity\WGReader(Config::$storageDir . DS . $dataFile);
     $reader->setCostFormat($costFormat);
     $reader->doRead();
     $functions = array();
     $shownTotal = 0;
     $breakdown = array('internal' => 0, 'user' => 0, 'class' => 0, 'include' => 0);
     for ($i = 1, $max = $reader->getFunctionCount(); $i < $max; ++$i) {
         $functionInfo = $reader->getFunctionInfo($i);
         if (strpos($functionInfo['functionName'], 'php::') !== FALSE) {
             $breakdown['internal'] += $functionInfo['summedSelfCost'];
             $humanKind = 'internal';
             $kind = 'blue';
         } elseif (false !== strpos($functionInfo['functionName'], 'require_once::') || false !== strpos($functionInfo['functionName'], 'require::') || false !== strpos($functionInfo['functionName'], 'include_once::') || false !== strpos($functionInfo['functionName'], 'include::')) {
             $breakdown['include'] += $functionInfo['summedSelfCost'];
             $humanKind = 'include';
             $kind = 'grey';
         } else {
             if (false !== strpos($functionInfo['functionName'], '->') || false !== strpos($functionInfo['functionName'], '::')) {
                 $breakdown['class'] += $functionInfo['summedSelfCost'];
                 $humanKind = 'class';
                 $kind = 'green';
             } else {
                 $breakdown['user'] += $functionInfo['summedSelfCost'];
                 $humanKind = 'procedural';
                 $kind = 'orange';
             }
         }
         if (!(int) $_GET['hideInternals'] || strpos($functionInfo['functionName'], 'php::') === false) {
             $shownTotal += $functionInfo['summedSelfCost'];
             $functions[$i] = $functionInfo;
             $functions[$i]['nr'] = $i;
             $functions[$i]['kind'] = $kind;
             $functions[$i]['humanKind'] = $humanKind;
         }
     }
     usort($functions, function ($a, $b) {
         $a = $a['summedSelfCost'];
         $b = $b['summedSelfCost'];
         if ($a == $b) {
             return 0;
         }
         return $a > $b ? -1 : 1;
     });
     $remainingCost = $shownTotal * $_GET['showFraction'];
     $result['functions'] = array();
     foreach ($functions as $function) {
         $remainingCost -= $function['summedSelfCost'];
         $result['functions'][] = $function;
         if ($remainingCost < 0) {
             break;
         }
     }
     $result['summedInvocationCount'] = $reader->getFunctionCount();
     $result['summedRunTime'] = $reader->formatCost($reader->getHeader('summary'), 'msec');
     $result['dataFile'] = $dataFile;
     $result['invokeUrl'] = $reader->getHeader('cmd');
     $result['runs'] = $reader->getHeader('runs');
     $result['breakdown'] = $breakdown;
     $result['mtime'] = date(Config::$dateFormat, filemtime(Config::xdebugOutputDir() . $dataFile));
     echo json_encode($result);
 }