本文整理汇总了PHP中xhprof_disable函数的典型用法代码示例。如果您正苦于以下问题:PHP xhprof_disable函数的具体用法?PHP xhprof_disable怎么用?PHP xhprof_disable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xhprof_disable函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: end
public function end()
{
$xhprof_data = xhprof_disable();
$xhprof_runs = new XHProfRuns_Default();
$run_id = $xhprof_runs->save_run($xhprof_data, $this->name);
return "<a href='http://localhost:8080/xhprof/xhprof_html/index.php?run={$run_id}&source=" . $this->name . "'>See result</a>";
}
开发者ID:manishkhanchandani,项目名称:mkgxy,代码行数:7,代码来源:XHPProfiling.php
示例2: stopProfiler
public static function stopProfiler()
{
if (self::$profilerStarted) {
$data = xhprof_disable();
$data = serialize($data);
$file_class = 'PhabricatorFile';
// Since these happen on GET we can't do guarded writes. These also
// sometimes happen after we've disposed of the write guard; in this
// case we need to disable the whole mechanism.
$use_scope = AphrontWriteGuard::isGuardActive();
if ($use_scope) {
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
} else {
AphrontWriteGuard::allowDangerousUnguardedWrites(true);
}
$caught = null;
try {
$file = call_user_func(array($file_class, 'newFromFileData'), $data, array('mime-type' => 'application/xhprof', 'name' => 'profile.xhprof'));
} catch (Exception $ex) {
$caught = $ex;
}
if ($use_scope) {
unset($unguarded);
} else {
AphrontWriteGuard::allowDangerousUnguardedWrites(false);
}
if ($caught) {
throw $caught;
} else {
return $file->getPHID();
}
} else {
return null;
}
}
开发者ID:nexeck,项目名称:phabricator,代码行数:35,代码来源:DarkConsoleXHProfPluginAPI.php
示例3: indexAction
public function indexAction()
{
$m_article = $this->load('Article');
$userID = $this->getSession('userID');
if ($userID) {
$buffer['username'] = $this->getSession('username');
// User Aritcles
$where = array('userID' => USER_ID);
$total = $m_article->Where($where)->Total();
$page = $this->get('page');
$page = $page ? $page : 1;
$size = 10;
$pages = ceil($total / $size);
$order = array('addTime' => 'DESC');
$start = ($page - 1) * $size;
$limit = $start . ',' . $size;
$url = '/user/profile';
$buffer['pageNav'] = generatePageLink($page, $pages, $url, $total);
$buffer['articles'] = $m_article->Where($where)->Order($order)->Limit($limit)->Select();
} else {
$this->redirect('/');
}
// 如果有 xhprof 则开启跟踪功能
if (function_exists('xhprof_disable')) {
$data = xhprof_disable();
include_once LIB_PATH . '/xhprof_lib/utils/xhprof_lib.php';
include_once LIB_PATH . '/xhprof_lib/utils/xhprof_runs.php';
$objXhprofRun = new XHProfRuns_Default();
$run_id = $objXhprofRun->save_run($data, 'xhprof');
}
$buffer['run_id'] = $run_id;
$this->getView()->assign($buffer);
}
开发者ID:GobYang,项目名称:thaidh,代码行数:33,代码来源:Profile.php
示例4: ADisable
public static function ADisable()
{
if (self::_isEnable()) {
return xhprof_disable();
}
return array();
}
开发者ID:jinghm318,项目名称:ko,代码行数:7,代码来源:Xhprof.php
示例5: profilingFinalize
function profilingFinalize($pre)
{
include_once "/usr/share/php5-xhprof/xhprof_lib/utils/xhprof_lib.php";
include_once "/usr/share/php5-xhprof/xhprof_lib/utils/xhprof_runs.php";
$xhprof_runs = new XHProfRuns_Default();
$xhprof_runs->save_run(xhprof_disable(), 'nagvis-' . $pre);
}
开发者ID:rlugojr,项目名称:nagvis,代码行数:7,代码来源:debug.php
示例6: save
/**
* @inheritdoc
*/
public function save()
{
if (function_exists('xhprof_disable')) {
$data = xhprof_disable();
}
return isset($data) && $data !== null ? $data : [];
}
开发者ID:hassiumsoft,项目名称:hasscms-app-vendor,代码行数:10,代码来源:XhprofPanel.php
示例7: stop
/**
* Stops XHProf profiling and saves profile data in var/log/xhprof
*
* @return mixed false|string (the run_id)|true (when nosave==true)
*/
public static function stop($dosave = true)
{
if (!extension_loaded('xhprof')) {
eZPerfLoggerDebug::writeWarning('Extension xhprof not loaded, can not stop profiling', __METHOD__);
return false;
}
if (!self::$profilingRunning) {
return false;
}
$xhprofData = xhprof_disable();
self::$profilingRunning = false;
if (!$dosave) {
return true;
}
if (!is_dir(self::$logdir)) {
mkdir(self::$logdir);
}
$logger = new XHProfRuns_Default(self::$logdir);
$runId = $logger->save_run($xhprofData, "xhprof");
if ($runId) {
// beside profiling data, save extra info in another file to make it more useful later
file_put_contents(self::$logdir . "/{$runId}.info", eZPerfLoggerApacheLogger::apacheLogLine('combined'));
self::$runs[] = $runId;
}
return $runId;
}
开发者ID:gggeek,项目名称:ezperformancelogger,代码行数:31,代码来源:ezxhproflogger.php
示例8: stop
/**
* Stop collecting profiling data.
*
* Only the first invocation of this method will effect the internal
* object state. Subsequent calls will return the data collected by the
* initial call.
*
* @return array Collected profiling data (possibly cached)
*/
public function stop()
{
if ($this->hieraData === null) {
$this->hieraData = $this->pruneData(xhprof_disable());
}
return $this->hieraData;
}
开发者ID:Acidburn0zzz,项目名称:mediawiki,代码行数:16,代码来源:Xhprof.php
示例9: 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);
}
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:26,代码来源:performanceTests.php
示例10: disable
/**
* 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();
}
}
开发者ID:claudinec,项目名称:galan-wiki,代码行数:12,代码来源:Xhprof.php
示例11: xhprof_stop
function xhprof_stop()
{
// 关闭xhprof
global $gearman_enabled;
$error = error_get_last();
$resp_time = sprintf("%.4f", $GLOBALS['AX_PAGE_END_TIME'] - $GLOBALS['AX_PAGE_START_TIME']);
if (!empty($error) || $GLOBALS['AX_XHPROF_IS_RUN'] || $resp_time >= $GLOBALS['AX_XHPROF_TIMEOUT']) {
$data = array();
$data['host'] = $_SERVER['HTTP_HOST'];
$data['uri'] = $_SERVER['REQUEST_URI'];
$data['client_time'] = date('Y-m-d H:i:s');
$data['resp_time'] = $resp_time;
$data['xhprof'] = null;
if ($GLOBALS['AX_XHPROF_IS_RUN']) {
$data['xhprof'] = xhprof_disable();
$GLOBALS['AX_XHPROF_IS_RUN'] = false;
}
$data['error'] = $error;
// 检查是否安装gearman扩展,并已设置gearman server
if ($gearman_enabled) {
$ret = do_background_job('xhprof.write', serialize($data));
echo "\n<!-- gearman save: {$ret} -->\n";
} else {
$xhprof_run = new XHProfRuns_DB();
$run_id = $xhprof_run->save_run($data);
echo "\n<!-- xhprof save, id: {$run_id} -->\n";
}
}
}
开发者ID:songliang89,项目名称:auto-xhprof,代码行数:29,代码来源:auto-xhprof.php
示例12: endProf
public static function endProf()
{
$xhprof_data = xhprof_disable();
$xhprof_runs = new XHProfRuns_Default();
$run_id = $xhprof_runs->save_run($xhprof_data, "xhprof_foo");
echo '<a href="/xhprof_html/index.php?run=' . $run_id . '&source=xhprof_foo" target="_blank">count</a>';
}
开发者ID:zhaozhiliang,项目名称:emblog531,代码行数:7,代码来源:XHProf.class.php
示例13: collect
/**
* Collects data.
*
* @param MvcEvent $mvcEvent
*/
public function collect(MvcEvent $mvcEvent)
{
$rawData = xhprof_disable();
$rawData = empty($rawData) ? [] : $rawData;
$data = $this->getFunctions($rawData);
$heaps = [];
foreach ($this->options->getMetrics() as $name => $options) {
$this->data[$name] = [];
$heaps[$name] = new MaxHeap();
}
if (!empty($data)) {
foreach ($data as $entry) {
/** @var Entry $entry */
foreach ($this->options->getMetrics() as $name => $options) {
if ($options['skipInternal'] && $entry->isInternal()) {
continue;
}
if (!empty($options['skipPattern']) && preg_match($options['skipPattern'], $entry->getName())) {
continue;
}
$heaps[$name]->insert(['name' => $entry->getName(), 'value' => $entry->{$options['getter']}()]);
}
}
foreach ($this->options->getMetrics() as $name => $options) {
for ($i = $options['limit']; $i--;) {
$value = $heaps[$name]->extract();
$this->data[$name][$value['name']] = $value['value'];
}
}
}
}
开发者ID:skpd,项目名称:profiler-toolbar,代码行数:36,代码来源:XhprofCollector.php
示例14: 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.
}
开发者ID:waqt,项目名称:kdweb,代码行数:35,代码来源:PerformanceController.class.php
示例15: register
private function register()
{
register_shutdown_function(function () {
$execTime = microtime(true) - START_TIME;
$memoryUsage = round((memory_get_usage() - START_MEMORY_USAGE) / 1024, 2);
$info = '执行时间: ' . round($execTime, 2) . 's, 内存使用: ' . $memoryUsage . 'KB';
$info .= ", 查询次数: " . Db::$queryCount . ", 慢查询数量: " . Db::$slowCount;
if ($this->xhporfEnabled) {
$route = str_replace('/', '_', CUR_ROUTE);
$xhprofData = xhprof_disable();
$dir = DATA_PATH . 'xhprof/';
if (is_dir($dir) || @mkdir($dir)) {
$xhprofRuns = new \XHProfRuns_Default($dir);
$runId = $xhprofRuns->save_run($xhprofData, $route);
$info .= ', 性能分析: <a href="' . $this->xhprofUrl . '?run=' . $runId . '&source=' . $route . '" target="_blank">' . $runId . '</a>';
}
}
$isAjax = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest';
$isGet = !empty($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) === 'get';
if ($this->showStatusBar && $isGet && !$isAjax) {
echo '<div style="padding:5px 0;background:#faebcc;text-align:center;">';
echo $info;
echo '</div>';
}
});
}
开发者ID:saoyor,项目名称:php-framework,代码行数:26,代码来源:Profiler.php
示例16: stop_xhprof_profiling
function stop_xhprof_profiling()
{
$xhprofData = xhprof_disable();
$xhprofNameSpace = 'predict';
$xhprofRuns = new XHProfRuns_Default();
$xhprofRunID = $xhprofRuns->save_run($xhprofData, $xhprofNameSpace);
}
开发者ID:stml,项目名称:auspex,代码行数:7,代码来源:benchmark.php
示例17: benchmark_end
public function benchmark_end()
{
$controller = MPF::get_instance()->get_current_controller();
$this->namespace = get_class($controller);
$run = xhprof_disable();
$this->xhprof_data = serialize($run);
}
开发者ID:uedcw,项目名称:webstory,代码行数:7,代码来源:Xhprof.php
示例18: collect
/**
* collect data
*/
public function collect()
{
if (!extension_loaded('xhprof')) {
throw new \RuntimeException('xhprof extension is not loaded');
}
$this->addData(\xhprof_disable());
}
开发者ID:itkg,项目名称:profiler,代码行数:10,代码来源:XhprofDataCollector.php
示例19: tearDown
public function tearDown()
{
if (!extension_loaded('xhprof')) {
return parent::tearDown();
}
$xhprofData = xhprof_disable();
$this->endTime = microtime(true);
if (defined('ARRAY_FILTER_USE_KEY')) {
// ignore all phpunit related keys
// var_dump($xhprofData);
$xhprofData = array_filter($xhprofData, function ($key) {
return !preg_match('/PHPUnit/', $key);
}, ARRAY_FILTER_USE_KEY);
}
include_once $_ENV['XHPROF_ROOT'] . "/xhprof_lib/utils/xhprof_lib.php";
include_once $_ENV['XHPROF_ROOT'] . "/xhprof_lib/utils/xhprof_runs.php";
$namespace = 'LazyRecord:' . $this->getName();
$runs = new XHProfRuns_Default();
$runId = $runs->save_run($xhprofData, $namespace);
$host = 'localhost';
if (isset($_ENV['XHPROF_HOST'])) {
$host = $_ENV['XHPROF_HOST'];
}
echo "\n---------------------------------\n";
printf("Profile test %d times spent %.2f seconds\n", $this->N, $this->endTime - $this->startTime);
printf("See profiling result at http://%s/index.php?run=%s&source=%s\n", $host, $runId, $namespace);
parent::tearDown();
}
开发者ID:appleboy,项目名称:LazyRecord,代码行数:28,代码来源:ModelProfileTestCase.php
示例20: xhprof_shutdown
function xhprof_shutdown()
{
global $xhprofMainConfig;
$xhprof_data = xhprof_disable();
if (function_exists('fastcgi_finish_request')) {
fastcgi_finish_request();
}
try {
require_once __DIR__ . '/../xhprof/classes/data.php';
$xhprof_data_obj = new \ay\xhprof\Data($xhprofMainConfig['pdo']);
$xhprof_data_obj->save($xhprof_data);
} catch (Exception $e) {
// old php versions don't like Exceptions in shutdown functions
// -> log them to have some usefull info in the php-log
if (PHP_VERSION_ID < 504000) {
if (function_exists('log_exception')) {
log_exception($e);
} else {
error_log($e->__toString());
}
}
// re-throw to show the caller something went wrong
throw $e;
}
}
开发者ID:sugarops,项目名称:xhprof.io,代码行数:25,代码来源:prepend.php
注:本文中的xhprof_disable函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论