public function testSearchEvents()
 {
     $allUsers = Tinebase_User::getInstance()->getFullUsers('');
     xhprof_enable();
     $numSearches = 0;
     foreach ($allUsers as $user) {
         if ($numSearches > 5) {
             break;
         }
         echo "getting month view for {$user->accountDisplayName}\n";
         $filterData = array(array('field' => 'container_id', 'operator' => 'in', 'value' => array('/personal/' . $user->getId(), '/shared')), array('field' => 'period', 'operator' => 'within', 'value' => array('from' => '2010-03-01 00:00:00', 'until' => '2010-04-01 00:00:00')));
         //            $filter = new Calendar_Model_EventFilter($filterData);
         //            $events = Calendar_Controller_Event::getInstance()->search($filter, NULL, FALSE);
         $this->_json->searchEvents($filterData, NULL);
         $numSearches += 1;
     }
     $xhprof_data = xhprof_disable();
     //Tinebase_Core::getDbProfiling();
     $XHPROF_ROOT = '/opt/local/www/php5-xhprof';
     include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_lib.php";
     include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_runs.php";
     $xhprof_runs = new XHProfRuns_Default();
     $run_id = $xhprof_runs->save_run($xhprof_data, "xhprof_tine20");
     echo "http://localhost/xhprof_html/index.php?run={$run_id}&source=xhprof_tine20 \n";
     print_r(Tinebase_Record_Abstract::$cns);
 }
Example #2
0
 /**
  * Start XHProf
  */
 public static function start()
 {
     self::$_isStarted = true;
     if (self::$_isEnabled && function_exists("xhprof_enable")) {
         xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
     }
 }
Example #3
0
 /**
  * Initialize workflow
  *
  * @param  ModuleManagerInterface $manager
  * @return void
  */
 public function init(ModuleManagerInterface $manager)
 {
     $eventManager = $manager->getEventManager();
     $eventManager->attach(ProfilerEvent::EVENT_PROFILER_INIT, function () {
         xhprof_enable(XHPROF_FLAGS_MEMORY);
     });
 }
Example #4
0
 public function handle(EventInterface $event)
 {
     xhprof_enable();
     if ($this->logger) {
         $this->logger->debug('Enabled XHProf');
     }
 }
Example #5
0
 /**
  * Start xhprof profiler
  */
 public function start()
 {
     if (!extension_loaded('xhprof')) {
         throw new \RuntimeException('xhprof extension is not loaded');
     }
     xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
 }
 /**
  * Profile the code contained inside the closure, returning
  * an array of XHProf profiling information. Optionally
  * filtered by a set of regular expressions which the called
  * function/class must match for the result to be returned.
  *
  * Special note: the $flags default value is hardcoded to
  * avoid errors when xhprof is not loaded - instead, this
  * causes a graceful "test skipped".
  *
  * @param \Closure $closure A standard Closure that will execute exactly the code that will be profiled, nothing more.
  * @param array $methodMatchExpressions An array of PERL regular expressions to filter which methods' results are returned.
  * @param integer $flags Standard XHPROF flags for what gets profiled. Default excludes built-in functions and CPU/memory.
  * @param array $options Optional further options (second argument for xhprof_enable).
  * @return array
  */
 protected function profileClosure(\Closure $closure, array $methodMatchExpressions = array(), $flags = 1, $options = array())
 {
     if (!$this->isProfilingExtensionLoaded()) {
         $this->markTestSkipped('XHProf is not installed; test must be skipped');
     }
     $folder = vfsStream::newDirectory('profiles');
     $backup = ini_set('xhprof.output_dir', vfsStream::url('profiles'));
     xhprof_enable($flags, $options);
     $closure();
     $profile = xhprof_disable();
     ini_set('xhprof.output_dir', $backup);
     if (!empty($methodMatchExpressions)) {
         foreach ($profile as $methodIdentifier => $_) {
             $keep = FALSE;
             foreach ($methodMatchExpressions as $expression) {
                 if (preg_match($expression, $methodIdentifier)) {
                     $keep = TRUE;
                 }
             }
             if (!$keep) {
                 unset($profile[$methodIdentifier]);
             }
         }
     }
     return $profile;
 }
Example #7
0
 /**
  * Start profiling the code
  */
 public function profileStart()
 {
     // don't profile internal php functions
     // show memory output
     \xhprof_enable(XHPROF_FLAGS_NO_BUILTINS | XHPROF_FLAGS_MEMORY);
     $this->xhprof_on = true;
 }
Example #8
0
 /**
  * Metoda odpowiada za uruchomienie profilowania
  * 
  * @access public
  * @static
  */
 public static function start() {
    $xhp_config = Xhprof_XHProfConfigFile::getInstance();
    $xhprof_enabled = $xhp_config->checkXhprofEnabled();
    if ($xhprof_enabled) {
       xhprof_enable(XHPROF_FLAGS_MEMORY + XHPROF_FLAGS_CPU);
    }
 }
 public function index()
 {
     function bar($x)
     {
         if ($x > 0) {
             bar($x - 1);
         }
     }
     function foo()
     {
         for ($idx = 0; $idx < 5; $idx++) {
             bar($idx);
             $x = strlen("abc");
         }
     }
     //开启调试
     xhprof_enable();
     // cpu:XHPROF_FLAGS_CPU 内存:XHPROF_FLAGS_MEMORY
     // 如果两个一起:XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY
     xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
     //要测试的php代码
     foo();
     //停止监测
     $xhprof_data = xhprof_disable();
     // display raw xhprof data for the profiler run
     print_r($xhprof_data);
     //包含工具类,在下载的 tgz 包中可以找到
     //$XHPROF_ROOT = realpath(dirname(__FILE__) .'/..');
     Vendor('Xhprof.autoload');
     //Vendor('Xhprof.xhprof_runs');
     //include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_lib.php";
     //include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_runs.php";
     // save raw data for this profiler run using default
     // implementation of iXHProfRuns.
 }
 public static function startProfiler()
 {
     self::includeXHProfLib();
     // Note: HPHP's implementation of XHProf currently requires an argument
     // to xhprof_enable() -- see Facebook Task #531011.
     xhprof_enable(0);
 }
 /**
  * Start to profile with xhprof
  *
  * @return void
  */
 public function profilerStart()
 {
     if (extension_loaded('xhprof')) {
         include_once $this->xhprofLibPath . 'utils/xhprof_lib.php';
         include_once $this->xhprofLibPath . 'utils/xhprof_runs.php';
         xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
     }
 }
Example #12
0
 /**
  * 前置拦截器,在所有Action运行全会进行拦截
  * 如果返回true,则拦截通过;如果返回false,则拦截
  * @return boolean 返回布尔类型,如果返回false,则截断
  */
 public function preHandle()
 {
     $config = InitPHP::getConfig();
     if ($config['is_xhprof']) {
         xhprof_enable();
     }
     return true;
 }
 public function start()
 {
     if (!$this->getSwitch()) {
         return FALSE;
     }
     xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
     $this->timeStart = microtime(TRUE);
 }
Example #14
0
 public function routerStartup(Yaf\Request_Abstract $request, Yaf\Response_Abstract $response)
 {
     //只能在php.ini中指定
     //ini_set('xhprof.output_dir', APPLICATION_PATH . '/data');
     // start profiling
     //        xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
     xhprof_enable();
 }
Example #15
0
 /**
  * Start xhprof profiler
  */
 public static function enable($flags = 0, $options = [])
 {
     if (self::isEnabled()) {
         throw new Exception('Xhprof profiling is already enabled.');
     }
     self::$enabled = true;
     xhprof_enable($flags, $options);
 }
 /**
  * Bootstrap method to be called during application bootstrap stage.
  * @param Application $app the application currently running
  */
 public function bootstrap($app)
 {
     if ((isset($_GET['_xhprof']) || isset($_COOKIE['_xhprof'])) && function_exists('xhprof_enable')) {
         $app->on(Application::EVENT_BEFORE_REQUEST, function () use($app) {
             \xhprof_enable(\XHPROF_FLAGS_CPU + \XHPROF_FLAGS_MEMORY);
         });
     }
 }
Example #17
0
 public function startProfiling()
 {
     $this->profiling = true;
     xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
     if ($this->logger) {
         $this->logger->debug('Enabled XHProf');
     }
 }
Example #18
0
function xhprof_start()
{
    // 打开xhprof
    global $xhprof_enabled;
    if ($xhprof_enabled) {
        xhprof_enable();
        $GLOBALS['AX_XHPROF_IS_RUN'] = true;
    }
}
Example #19
0
 /**
  * Constructor
  *
  * @param string $sourceId      The application identifier
  * @param array  $options       Custom options
  *      - flags     : XHPROF_FLAGS_XXXX constants for xhprof_enable()
  *      - libPath   : Path to xhprof PHP classes (default: xhprof_lib/utils)
  *      - baseUrl   : Base URL for the XHProf viewer (default: /)
  *      - output    : If true will append an html link to the HTML response (default: false)
  */
 public function __construct($sourceId, $options = array())
 {
     $this->_source = $sourceId;
     $this->_options = $options;
     if (function_exists('xhprof_enable')) {
         $flags = isset($options['flags']) ? $options['flags'] : XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY;
         xhprof_enable($flags);
     }
 }
Example #20
0
 public function start()
 {
     if (!function_exists('xhprof_enable')) {
         return false;
     } else {
         xhprof_enable(XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY);
         return true;
     }
 }
Example #21
0
 /**
  * @param $msg (default '')
  **/
 function start($msg = '')
 {
     if (!self::$run && function_exists('xhprof_enable')) {
         xhprof_enable();
         if (class_exists('Toolbox')) {
             Toolbox::logDebug("Start profiling with XHProf", $msg);
         }
         self::$run = true;
     }
 }
 /**
  * Starts XHPRof profiling
  *
  * @return bool
  *
  */
 public static function start($flags = 0, $options = array())
 {
     if (!extension_loaded('xhprof')) {
         eZPerfLoggerDebug::writeWarning('Extension xhprof not loaded, can not start profiling', __METHOD__);
         return false;
     }
     xhprof_enable($flags + XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY, $options);
     self::$profilingRunning = true;
     return true;
 }
Example #23
0
 public static function begin($params = null, $ignore = null)
 {
     if (!self::isExtension()) {
         die("没有xhprof扩展!");
     }
     // 可以return掉 则不影响正常程序
     $params = $params ? $params : XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY + XHPROF_FLAGS_NO_BUILTINS;
     $ignore = $ignore ? $ignore : array('ignored_functions' => array('call_user_func', 'call_user_func_array'));
     xhprof_enable($params, $ignore);
 }
Example #24
0
 static function start()
 {
     self::$start_time = microtime(true);
     if (function_exists('xhprof_enable')) {
         xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
     }
     ob_start(function ($buf) {
         return self::getMsg() . $buf;
     });
 }
Example #25
0
 /**
  * プロファイリングスタート
  *
  * BEAR_Prof::stop()でストップを指定しないときはスクリプト終了までのプロファイルが取れます。
  *
  * @return void
  */
 public static function start()
 {
     if (function_exists('xhprof_enable')) {
         register_shutdown_function(array(__CLASS__, 'stop'));
         xhprof_enable();
         //xhprof_enable(XHPROF_FLAGS_NO_BUILTINS | XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY);
     } else {
         trigger_error('xhprof is not enabled.', E_USER_ERROR);
     }
 }
Example #26
0
 public static function start($key = 'ALL')
 {
     self::$xhprof = Config::getField('project', 'xhprof', 0) && \function_exists('xhprof_enable');
     if (self::$xhprof) {
         require ZPHP::getZPath() . DS . 'lib' . DS . 'xhprof_lib' . DS . 'utils' . DS . 'xhprof_lib.php';
         require ZPHP::getZPath() . DS . 'lib' . DS . 'xhprof_lib' . DS . 'utils' . DS . 'xhprof_runs.php';
         \xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
     }
     self::$records[$key]['start_time'] = self::getMicroTime();
     self::$records[$key]['memory_use'] = memory_get_usage();
 }
Example #27
0
 /**
  * Starts the profiling
  */
 public function startProfiling()
 {
     if (PHP_SAPI == 'cli') {
         $_SERVER['REMOTE_ADDR'] = null;
         $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
     }
     if (function_exists('xhprof_enable') && count($this->probes) > 0) {
         $this->profiling = true;
         xhprof_enable($this->memory ? XHPROF_FLAGS_MEMORY : null);
     }
 }
Example #28
0
 /**
  * Starts XHProf
  * 
  * @return boolean
  */
 public static function start()
 {
     if (extension_loaded('xhprof')) {
         include_once '../../xhprof-master/xhprof_lib/utils/xhprof_lib.php';
         include_once '../../xhprof-master/xhprof_lib/utils/xhprof_runs.php';
         xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
         return true;
     } else {
         return false;
     }
 }
Example #29
0
 /**
  * Create a new ProfilerXhprof instance and bind to request shutdown event to transfer
  * collected data.
  */
 public function __construct()
 {
     if (!self::$initialized) {
         self::$initialized = true;
         self::$ruUsageStart = $this->getCpuTime();
         if (!function_exists('xhprof_enable')) {
             return;
         }
         xhprof_enable(XHPROF_FLAGS_NO_BUILTINS);
         register_shutdown_function(array($this, 'finalize'));
     }
 }
Example #30
0
 /**
  * Start xhprof profiler
  *
  * ### Options
  *
  * - `flags`
  * - `ignored_functions`
  *
  * @param array $options List options passed to xhprof_enable, if none default configuration will be used
  * @return void
  */
 public static function start($options = array())
 {
     if (!self::$_initiated) {
         self::_initialize();
     }
     // Merge default configuration into provided options
     $options += (array) Configure::read('XHProf');
     // Start profiling
     xhprof_enable($options['flags'], array('ignored_functions' => $options['ignored_functions']));
     // Set as started
     self::$_started = true;
 }