本文整理汇总了PHP中XHProfRuns_Default类的典型用法代码示例。如果您正苦于以下问题:PHP XHProfRuns_Default类的具体用法?PHP XHProfRuns_Default怎么用?PHP XHProfRuns_Default使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XHProfRuns_Default类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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);
}
示例3: 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>";
}
示例4: stop_xhprof_profiling
function stop_xhprof_profiling()
{
$xhprofData = xhprof_disable();
$xhprofNameSpace = 'predict';
$xhprofRuns = new XHProfRuns_Default();
$xhprofRunID = $xhprofRuns->save_run($xhprofData, $xhprofNameSpace);
}
示例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);
}
示例6: 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);
}
示例7: 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>';
}
示例8: 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>';
}
});
}
示例9: finish
/**
* Stop and save the xhprof profiler run
*
* @return string Saved run id
*/
public static function finish()
{
// Stop profiling
$data = self::stop();
// Save the run
$xhprof = new XHProfRuns_Default();
$runId = $xhprof->save_run($data, Configure::read('XHProf.namespace'));
return $runId;
}
示例10: xhprof
static function xhprof($xhprof_data, $res_name = "xhprof_res")
{
include_once dc_root . 'xhprof_lib/xhprof_lib.php';
include_once dc_root . 'xhprof_lib/xhprof_runs.php';
$xhprof_runs = new XHProfRuns_Default();
$run_id = $xhprof_runs->save_run($xhprof_data, $res_name);
$show_url = dc_url . 'xhprof_html/index.php?run=' . $run_id . '&source=' . $res_name;
return '<a href="' . $show_url . '" target="_blank">XHPROF_RESULT</a>';
}
示例11: Save
/**
* save run data
*
* @param array $run run data
* @param string $namespace save namespace
* @return string id
*/
static function Save($run, $namespace, $root = '')
{
if ($root) {
$root = rtrim($root, '/') . '/';
}
include_once $root . "xhprof_lib/utils/xhprof_lib.php";
include_once $root . "xhprof_lib/utils/xhprof_runs.php";
$xhprof = new XHProfRuns_Default();
return $xhprof->save_run($run, $namespace);
}
示例12: save
public function save()
{
if (!$this->aResult) {
$this->launchException('Cannot save profile, no result found');
}
require_once self::ROOT . '/utils/xhprof_lib.php';
require_once self::ROOT . '/utils/xhprof_runs.php';
$xhprof_runs = new \XHProfRuns_Default();
$run_id = $xhprof_runs->save_run($this->aResult, "xhprof_testing");
}
示例13: xhprofclose
function xhprofclose()
{
$xhprof_data = xhprof_disable();
$xhprof_location = "/data/htdocs/xhprof";
include_once "{$xhprof_location}/xhprof_lib/utils/xhprof_lib.php";
include_once "{$xhprof_location}/xhprof_lib/utils/xhprof_runs.php";
$xhprof_runs = new XHProfRuns_Default();
$identifer = str_replace(array('/', '?', '.', '=', '&'), '_', $_SERVER['REQUEST_URI']);
$xhprof_runs->save_run($xhprof_data, $identifer);
}
示例14: xhprof_shutdown_function
function xhprof_shutdown_function()
{
global $_xhprof;
if ($_xhprof['doprofile'] === true) {
$profiler_namespace = $_xhprof['namespace'];
// namespace for your application
$xhprof_data = xhprof_disable();
$xhprof_runs = new XHProfRuns_Default();
$run_id = $xhprof_runs->save_run($xhprof_data, $profiler_namespace, null, $_xhprof);
}
}
示例15: end_xhprof
function end_xhprof($domain = "dachuwang")
{
try {
//end profiling
$xhprof_data = xhprof_disable();
$xhprof_runs = new XHProfRuns_Default();
$run_id = $xhprof_runs->save_run($xhprof_data, $domain);
} catch (Exception $e) {
return FALSE;
}
return C("xhprof.url") . "/xhprof_html/index.php?run={$run_id}&source={$domain}";
}