get() public method

Read data from the profile run.
public get ( string $key, string $metric = null ) : null | float
$key string The function key name to read.
$metric string The metric to read.
return null | float
Ejemplo n.º 1
0
 public function testGet()
 {
     $fixture = $this->_fixture[0];
     $profile = new Xhgui_Profile($fixture);
     $this->assertEquals($fixture['profile']['main()']['wt'], $profile->get('main()', 'wt'));
     $expected = $fixture['profile']['main()'];
     $result = $profile->get('main()');
     unset($result['parents']);
     $this->assertEquals($expected, $result);
     $this->assertNull($profile->get('main()', 'derp'));
     $this->assertNull($profile->get('derp', 'wt'));
 }
Ejemplo n.º 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);
 }