Exemplo n.º 1
0
 /**
  * @return XhprofData
  */
 public function getXhprofData()
 {
     if (!$this->xhprofData) {
         $this->xhprofData = new XhprofData(Xhprof::disable(), $this->params);
     }
     return $this->xhprofData;
 }
Exemplo n.º 2
0
 /**
  * Stop xhprof profiler
  *
  * @return array|null xhprof data from the run, or null if xhprof was not running.
  */
 public static function disable()
 {
     if (self::isEnabled()) {
         self::$enabled = false;
         return xhprof_disable();
     }
 }
Exemplo n.º 3
0
 public static function start()
 {
     if (!self::isOpen()) {
         return false;
     }
     if (self::$is_start === true) {
         return false;
     }
     //XHPROF_FLAGS_NO_BUILTINS 是否跳过内部函数
     function_exists('xhprof_enable') && xhprof_enable(XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY);
     self::$is_start = true;
 }
Exemplo n.º 4
0
date_default_timezone_set('Asia/Shanghai');
setlocale(LC_ALL, 'en_US.utf-8');
ini_set('session.hash_function', 1);
session_start();
version_compare(PHP_VERSION, '5.3', '<') and exit('need PHP 5.3 or newer.');
define('DEBUG', true);
define('START_TIME', microtime(TRUE));
define('START_MEMORY', memory_get_usage());
if (DEBUG === true) {
    ini_set('display_errors', 1);
    error_reporting(E_ALL);
} else {
    ini_set('display_errors', 0);
    error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE);
}
define('DOCROOT', str_replace('\\', '/', realpath(dirname(__FILE__))) . "/");
define('SYSPATH', DOCROOT . '../../framework/');
define('APPPATH', DOCROOT . '../application/');
require SYSPATH . 'librarys/Loader.class.php';
try {
    Loader::registerAutoload();
    Xhprof::start();
    Request::instance()->start()->execute();
    Xhprof::end();
} catch (Exception $e) {
    if (DEBUG === true) {
        echo "错误代码:" . $e->getCode() . "<br>错误信息:" . $e->getMessage() . '<br>文件:' . $e->getFile() . '<br>行号:' . $e->getLine() . '<br>堆栈信息:' . $e->getTraceAsString();
    } else {
        //Util::ShowMessage('', "/error.html");
    }
}
Exemplo n.º 5
0
 /**
  * Retrieve raw data from xhprof
  * @return array
  */
 public function getRawData()
 {
     return $this->xhprof->getRawData();
 }
Exemplo n.º 6
0
 /**
  * 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;
 }