本文整理汇总了PHP中xhprof_enable函数的典型用法代码示例。如果您正苦于以下问题:PHP xhprof_enable函数的具体用法?PHP xhprof_enable怎么用?PHP xhprof_enable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xhprof_enable函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSearchEvents
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);
}
示例2: start
/**
* Start XHProf
*/
public static function start()
{
self::$_isStarted = true;
if (self::$_isEnabled && function_exists("xhprof_enable")) {
xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
}
}
示例3: init
/**
* 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);
});
}
示例4: handle
public function handle(EventInterface $event)
{
xhprof_enable();
if ($this->logger) {
$this->logger->debug('Enabled XHProf');
}
}
示例5: start
/**
* 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);
}
示例6: profileClosure
/**
* 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;
}
示例7: profileStart
/**
* 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;
}
示例8: start
/**
* 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);
}
}
示例9: index
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.
}
示例10: startProfiler
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);
}
示例11: profilerStart
/**
* 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);
}
}
示例12: preHandle
/**
* 前置拦截器,在所有Action运行全会进行拦截
* 如果返回true,则拦截通过;如果返回false,则拦截
* @return boolean 返回布尔类型,如果返回false,则截断
*/
public function preHandle()
{
$config = InitPHP::getConfig();
if ($config['is_xhprof']) {
xhprof_enable();
}
return true;
}
示例13: start
public function start()
{
if (!$this->getSwitch()) {
return FALSE;
}
xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
$this->timeStart = microtime(TRUE);
}
示例14: routerStartup
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();
}
示例15: enable
/**
* 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);
}