/** * Get an Xhprof instance that has been primed with a set of known testing * data. Tests for the Xhprof class should laregly be concerned with * evaluating the manipulations of the data collected by xhprof rather * than the data collection process itself. * * The returned Xhprof instance primed will be with a data set created by * running this trivial program using the PECL xhprof implementation: * @code * function bar( $x ) { * if ( $x > 0 ) { * bar($x - 1); * } * } * function foo() { * for ( $idx = 0; $idx < 2; $idx++ ) { * bar( $idx ); * $x = strlen( 'abc' ); * } * } * xhprof_enable( XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY ); * foo(); * $x = xhprof_disable(); * var_export( $x ); * @endcode * * @return Xhprof */ protected function getXhprofFixture(array $opts = array()) { $xhprof = new Xhprof($opts); $xhprof->loadRawData(array('foo==>bar' => array('ct' => 2, 'wt' => 57, 'cpu' => 92, 'mu' => 1896, 'pmu' => 0), 'foo==>strlen' => array('ct' => 2, 'wt' => 21, 'cpu' => 141, 'mu' => 752, 'pmu' => 0), 'bar==>bar@1' => array('ct' => 1, 'wt' => 18, 'cpu' => 19, 'mu' => 752, 'pmu' => 0), 'main()==>foo' => array('ct' => 1, 'wt' => 304, 'cpu' => 307, 'mu' => 4008, 'pmu' => 0), 'main()==>xhprof_disable' => array('ct' => 1, 'wt' => 8, 'cpu' => 10, 'mu' => 768, 'pmu' => 392), 'main()' => array('ct' => 1, 'wt' => 353, 'cpu' => 351, 'mu' => 6112, 'pmu' => 1424))); return $xhprof; }