getRelatives() публичный Метод

The parent/children arrays will contain all the callers + callees of the symbol given. The current index will give the total inclusive values for all properties.
public getRelatives ( string $symbol, string $metric = null, float $threshold ) : array
$symbol string The name of the function/method to find relatives for.
$metric string The metric to compare $threshold with.
$threshold float The threshold to exclude child functions at. Any function that represents less than this percentage of the current metric will be filtered out.
Результат array List of (parent, current, children)
Пример #1
0
 public function testGetRelativesWithThreshold()
 {
     $data = array('main()' => array('ct' => 1, 'wt' => 100), 'main()==>other_func' => array('ct' => 1, 'cpu' => 1, 'wt' => 50, 'mu' => 1, 'pmu' => 1), 'main()==>your_func' => array('ct' => 1, 'cpu' => 1, 'wt' => 50, 'mu' => 1, 'pmu' => 1), 'other_func==>func' => array('ct' => 1, 'cpu' => 1, 'wt' => 10, 'mu' => 1, 'pmu' => 1), 'other_func==>isset' => array('ct' => 10, 'cpu' => 10, 'wt' => 1, 'mu' => 5, 'pmu' => 1), 'your_func==>func' => array('ct' => 1, 'cpu' => 1, 'wt' => 1, 'mu' => 1, 'pmu' => 1), 'func==>strlen' => array('ct' => 1, 'cpu' => 1, 'wt' => 1, 'mu' => 1, 'pmu' => 1), 'func==>isset' => array('ct' => 1, 'cpu' => 1, 'wt' => 1, 'mu' => 1, 'pmu' => 1));
     $profile = new Xhgui_Profile(array('profile' => $data));
     $result = $profile->getRelatives('other_func', 'wt', 0.1);
     $this->assertCount(3, $result);
     list($parent, $current, $children) = $result;
     $this->assertCount(1, $parent);
     $this->assertEquals('main()', $parent[0]['function']);
     $this->assertCount(1, $children, 'One method below threshold');
     $this->assertEquals('func', $children[0]['function']);
 }
Пример #2
0
 public function testGetRelatives()
 {
     $data = array('main()' => array(), 'main()==>other_func' => array('ct' => 1, 'cpu' => 1, 'wt' => 1, 'mu' => 1, 'pmu' => 1), 'main()==>your_func' => array('ct' => 1, 'cpu' => 1, 'wt' => 1, 'mu' => 1, 'pmu' => 1), 'other_func==>func' => array('ct' => 1, 'cpu' => 1, 'wt' => 1, 'mu' => 1, 'pmu' => 1), 'other_func==>isset' => array('ct' => 10, 'cpu' => 10, 'wt' => 1, 'mu' => 5, 'pmu' => 1), 'your_func==>func' => array('ct' => 1, 'cpu' => 1, 'wt' => 1, 'mu' => 1, 'pmu' => 1), 'func==>strlen' => array('ct' => 1, 'cpu' => 1, 'wt' => 1, 'mu' => 1, 'pmu' => 1), 'func==>isset' => array('ct' => 1, 'cpu' => 1, 'wt' => 1, 'mu' => 1, 'pmu' => 1));
     $profile = new Xhgui_Profile(array('profile' => $data));
     $result = $profile->getRelatives('not there at all');
     $this->assertCount(3, $result);
     $this->assertEquals(array(), $result[0]);
     $this->assertEquals(array(), $result[1]);
     $this->assertEquals(array(), $result[2]);
     $result = $profile->getRelatives('func');
     $this->assertCount(3, $result);
     list($parent, $current, $children) = $result;
     $this->assertCount(2, $parent);
     $this->assertEquals('other_func', $parent[0]['function']);
     $this->assertEquals('your_func', $parent[1]['function']);
     $this->assertCount(2, $children);
     $this->assertEquals('strlen', $children[0]['function']);
     $this->assertEquals('isset', $children[1]['function']);
     $this->assertEquals('func', $current['function']);
     $this->assertEquals(2, $current['ct']);
     $this->assertEquals(2, $current['wt']);
     $this->assertEquals(2, $current['mu']);
     $this->assertEquals(2, $current['pmu']);
 }