Provides method to manipulate the data from a single profile run.
Example #1
0
 public function testGetFlamegraph()
 {
     $fixture = $this->_fixture[0];
     $profile = new Xhgui_Profile($fixture);
     $result = $profile->getFlamegraph();
     $expected = array('data' => array('name' => 'main()', 'value' => 50139, 'children' => array(array('name' => 'strpos()', 'value' => 600))), 'sort' => array('main()' => 0, 'strpos()' => 1));
     $this->assertEquals($expected, $result);
 }
Example #2
0
 /**
  * Compare this run to another run.
  *
  * @param Xhgui_Profile $head The other run to compare with
  * @return array An array of comparison data.
  */
 public function compare(Xhgui_Profile $head)
 {
     $this->calculateSelf();
     $head->calculateSelf();
     $keys = array_merge($this->_keys, $this->_exclusiveKeys);
     $emptyData = array_fill_keys($keys, 0);
     $diffPercent = array();
     $diff = array();
     foreach ($this->_collapsed as $key => $baseData) {
         $headData = $head->get($key);
         if (!$headData) {
             $diff[$key] = $this->_diffKeys($emptyData, $baseData);
             continue;
         }
         $diff[$key] = $this->_diffKeys($headData, $baseData);
         if ($key === 'main()') {
             $diffPercent[$key] = $this->_diffPercentKeys($headData, $baseData);
         }
     }
     $diff['functionCount'] = $head->getFunctionCount() - $this->getFunctionCount();
     $diffPercent['functionCount'] = $head->getFunctionCount() / $this->getFunctionCount();
     return array('base' => $this, 'head' => $head, 'diff' => $diff, 'diffPercent' => $diffPercent);
 }
Example #3
0
 public function testGetCallgraphNoDuplicates()
 {
     $profile = new Xhgui_Profile($this->_fixture[2]);
     $expected = array('metric' => 'wt', 'total' => 50139, 'nodes' => array(array('name' => 'main()', 'value' => 50139, 'callCount' => 1), array('name' => 'load_file()', 'value' => 10000, 'callCount' => 1), array('name' => 'open()', 'value' => 10000, 'callCount' => 2), array('name' => 'strlen()', 'value' => 5000, 'callCount' => 1), array('name' => 'parse_string()', 'value' => 10000, 'callCount' => 1)), 'links' => array(array('source' => 'main()', 'target' => 'load_file()', 'callCount' => 1), array('source' => 'load_file()', 'target' => 'open()', 'callCount' => 2), array('source' => 'open()', 'target' => 'strlen()', 'callCount' => 1), array('source' => 'main()', 'target' => 'parse_string()', 'callCount' => 1), array('source' => 'parse_string()', 'target' => 'open()', 'callCount' => 2)));
     $result = $profile->getCallgraph();
     $this->assertEquals($expected, $result);
 }
Example #4
0
 public function testGetDateFallback()
 {
     $data = array('meta' => array('SERVER' => array()));
     $profile = new Xhgui_Profile($data);
     $result = $profile->getDate();
     $this->assertInstanceOf('DateTime', $result);
 }