예제 #1
0
 public function testCaller()
 {
     $caller = new Entry();
     $caller->setName('testCaller');
     $this->entry->setCaller($caller);
     $this->assertSame('testCaller', $this->entry->getCaller()->getName());
 }
예제 #2
0
 private function getFunctions(array $data)
 {
     $data = array_reverse($data, true);
     $collection = ['byName' => [], 'byOrder' => []];
     $position = 0;
     $internalFunctions = get_defined_functions();
     $internalFunctions = array_flip($internalFunctions['internal']);
     foreach ($data as $name => $values) {
         $entry = new Entry();
         $entry->setCalls($values['ct']);
         $entry->setInclusiveTime($values['wt']);
         $entry->setInclusiveMemory($values['pmu']);
         $caller = explode('==>', $name, 2);
         if (count($caller) === 1) {
             if (isset($collection['byOrder'][$position - 1])) {
                 $entry->setCaller($collection['byOrder'][$position - 1]);
             }
             $entry->setName($caller[0]);
         } else {
             if (isset($collection['byName'][$caller[0]])) {
                 /** @var Entry $parent */
                 $parent = $collection['byName'][$caller[0]];
             } else {
                 $searchPosition = $position;
                 while (isset($collection['byOrder'][--$searchPosition])) {
                     if ($collection['byOrder'][$searchPosition]->getName() === $caller[0]) {
                         /** @var Entry $parent */
                         $parent = $collection['byOrder'][$searchPosition];
                         break;
                     }
                 }
             }
             if (!empty($parent)) {
                 $parent->addCallee($entry);
                 $entry->setCaller($parent);
             }
             $entry->setName($caller[1]);
         }
         $entry->setInternal(array_key_exists($entry->getName(), $internalFunctions));
         $collection['byOrder'][$position++] = $entry;
         $collection['byName'][$name] = $entry;
     }
     foreach ($collection['byName'] as $entry) {
         $this->countExclusive($entry);
     }
     return $collection['byName'];
 }