本文整理汇总了PHP中Yii::endProfile方法的典型用法代码示例。如果您正苦于以下问题:PHP Yii::endProfile方法的具体用法?PHP Yii::endProfile怎么用?PHP Yii::endProfile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Yii
的用法示例。
在下文中一共展示了Yii::endProfile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionIndex
public function actionIndex()
{
$this->failIfNotAJsonRpcRequest();
Yii::beginProfile('service.request');
$request = $result = null;
try {
$request = json_decode(file_get_contents('php://input'), true);
$this->failIfRequestIsInvalid($request);
try {
$class = new ReflectionClass($this->controller);
if (!$class->hasMethod($request['method'])) {
throw new JsonRpcException("Method not found", -32601);
}
$method = $class->getMethod($request['method']);
ob_start();
Yii::beginProfile('service.request.action');
$result = $method->invokeArgs($this->controller, isset($request['params']) ? $request['params'] : null);
Yii::endProfile('service.request.action');
$output = ob_get_clean();
if ($output) {
Yii::log($output, CLogger::LEVEL_INFO, 'service.output');
}
} catch (Exception $e) {
Yii::log($e, CLogger::LEVEL_ERROR, 'service.error');
throw new JsonRpcException($e->getMessage(), -32603);
}
if (!empty($request['id'])) {
echo json_encode(array('jsonrpc' => '2.0', 'id' => $request['id'], 'result' => $output));
}
} catch (JsonRpcException $e) {
echo json_encode(array('jsonrpc' => '2.0', 'id' => isset($request['id']) ? $request['id'] : null, 'error' => $e->getErrorAsArray()));
}
Yii::endProfile('service.request');
}
示例2: process
/**
* @param DataEntityProvider[] $providers
* @param ActionData $actionData
* @param array $packed
* @param array $providedKeys
*
* @return mixed
*/
public static function process($providers, &$actionData, &$packed, &$providedKeys)
{
$result = [];
$providedKeys = [];
foreach ($providers as $i => $provider) {
$profileKey = "DataProviderProcessor: {$i}";
Yii::beginProfile($profileKey);
//! @todo Add check for correct class names here
/** @var DataEntityProvider $instance */
$instance = Yii::createObject($provider);
$providerResult = $instance->getEntities($actionData);
$keys = [];
array_walk($providerResult, function ($materials, $regionKey) use(&$keys) {
$result = [];
array_walk($materials, function ($data, $materialIndex) use(&$result) {
$result[$materialIndex] = array_keys($data);
});
$keys[$regionKey] = $result;
});
$providedKeys[$i] = $keys;
$result = ArrayHelper::merge($result, $providerResult);
$packed[$i] = $instance->pack();
Yii::endProfile($profileKey);
}
return $result;
}
示例3: getData
public function getData()
{
\Yii::beginProfile('admin-menu');
if ($this->isLoaded) {
return (array) $this->groups;
}
$paths[] = \Yii::getAlias('@common/config/admin/menu.php');
$paths[] = \Yii::getAlias('@app/config/admin/menu.php');
foreach (\Yii::$app->extensions as $code => $data) {
if ($data['alias']) {
foreach ($data['alias'] as $code => $path) {
$adminMenuFile = $path . '/config/admin/menu.php';
if (file_exists($adminMenuFile)) {
$menuGroups = (array) (include_once $adminMenuFile);
$this->groups = ArrayHelper::merge($this->groups, $menuGroups);
}
}
}
}
foreach ($paths as $path) {
if (file_exists($path)) {
$menuGroups = (array) (include_once $path);
$this->groups = ArrayHelper::merge($this->groups, $menuGroups);
}
}
ArrayHelper::multisort($this->groups, 'priority');
$this->isLoaded = true;
\Yii::endProfile('admin-menu');
return (array) $this->groups;
}
示例4: actionUpdate
public function actionUpdate($fid = 0, $gid = 0, $sort = '')
{
$timer = new CountTimer();
$cacheToken = 'cache-update';
Yii::beginProfile($cacheToken);
ob_start();
// 生成版块列表缓存
$this->forward('forum/forumlist', false);
// 生成帖子列表缓存
$sortArr = array('', 'new', 'marrow', 'top');
$fids = $this->_getFids($fid);
$uids = $this->_getUidsByGid($gid);
foreach ($sortArr as $sort) {
foreach ($fids as $fid) {
foreach ($uids as $uid) {
$_GET = array_merge($_GET, array('hacker_uid' => $uid, 'boardId' => $fid, 'page' => 1, 'pageSize' => 10, 'sortby' => $sort));
$res = $this->forward('forum/topiclist', false);
ob_clean();
}
}
}
ob_end_clean();
var_dump($timer->stop());
Yii::endProfile($cacheToken);
}
示例5: init
public function init()
{
$this->defaultAttributes = $this->attributes;
\Yii::beginProfile("Init: " . $this->className());
$this->initSettings();
\Yii::endProfile("Init: " . $this->className());
}
示例6: combineBundles
/**
* @param Event $event
*/
public function combineBundles(Event $event)
{
if (!$this->enabled) {
return;
}
$token = 'Combine bundles for page';
\Yii::beginProfile($token, __METHOD__);
$this->bundles = $this->owner->assetBundles;
$this->setAssetManager($this->owner->getAssetManager());
// Assemble monolith assets
foreach ($this->bundles as $name => $bundle) {
// If this is monolith bundle
if (ArrayHelper::getValue($bundle->publishOptions, 'monolith', false)) {
// If it already processed and have no dependency
if (empty($bundle->depends) && ArrayHelper::getValue($bundle->publishOptions, 'accProcessed', false)) {
$this->registerMonolith($bundle);
} else {
$this->assembleMonolith([$name => $bundle], $bundle->jsOptions, $bundle->cssOptions);
}
}
}
// Assemble rest of the assets
$this->assembleMonolith($this->bundles);
$this->owner->assetBundles = [];
\Yii::endProfile($token, __METHOD__);
}
示例7: run
/**
* @return string
*/
public function run()
{
if (YII_ENV == 'prod') {
try {
\Yii::beginProfile("Run: " . $this->_token);
$content = $this->_run();
\Yii::endProfile("Run: " . $this->_token);
} catch (\Exception $e) {
$content = \Yii::t('app', 'Error widget {class}', ['class' => $this->className()]) . " (" . $this->descriptor->name . "): " . $e->getMessage();
}
} else {
\Yii::beginProfile("Run: " . $this->_token);
$content = $this->_run();
\Yii::endProfile("Run: " . $this->_token);
}
\Yii::$app->cmsToolbar->initEnabled();
if (\Yii::$app->cmsToolbar->editWidgets == Cms::BOOL_Y && \Yii::$app->cmsToolbar->enabled) {
$pre = "";
/*$pre = Html::tag('pre', Json::encode($this->attributes), [
'style' => 'display: none;'
]);*/
$id = 'sx-infoblock-' . $this->getId();
$this->getView()->registerJs(<<<JS
new sx.classes.toolbar.EditViewBlock({'id' : '{$id}'});
JS
);
return Html::tag('div', $pre . (string) $content, ['class' => 'skeeks-cms-toolbar-edit-view-block', 'id' => $id, 'title' => \Yii::t('app', "Double-click on the block will open the settings manager"), 'data' => ['id' => $this->getId(), 'config-url' => $this->getEditUrl()]]);
}
return $content;
}
示例8: runProfilingSampleLoop
private function runProfilingSampleLoop()
{
Yii::beginProfile('dummy method');
for ($i = 0; $i < 100; $i++) {
$a = 1;
}
Yii::endProfile('dummy method');
}
示例9: today
/**
* Returns amount of today comments.
*
* @return int Number of today comments.
* @since 0.1.0
*/
public function today()
{
$token = 'comment.today';
\Yii::beginProfile($token);
$dateTime = new \DateTime();
$dateTime->sub(new \DateInterval('P1D'));
$amount = (int) $this->count('created >= :today', array(':today' => $dateTime->format(\DateTime::ISO8601)));
\Yii::endProfile($token);
return $amount;
}
示例10: tryToRunMethod
/**
* @return mixed
* @throws Exception
*/
protected function tryToRunMethod()
{
$method = $this->getHandler();
Yii::beginProfile('service.request.action');
$output = $this->runMethod($method, $this->getParams($method));
Yii::endProfile('service.request.action');
Yii::info($method, 'service.output');
Yii::info($output, 'service.output');
return $output;
}
示例11: actionIndex
public function actionIndex()
{
Yii::beginProfile('wishlist');
$criteria = PropertyWishlistApi::getCriteriaObjectForUser(Yii::app()->user->id);
$count = Property::model()->count($criteria);
$pages = new CPagination($count);
$pages->pageSize = Yii::app()->params['resultsPerPage'];
$pages->applyLimit($criteria);
$properties = PropertyWishlistApi::searchWithCriteria($criteria);
// $projects = ProjectWishlistApi::getWishlistProjectsByUserId(Yii::app()->user->id);
$this->render('index', array('properties' => $properties, 'count' => $count, 'pages' => $pages));
Yii::endProfile('wishlist');
}
示例12: actionIndex
public function actionIndex()
{
Yii::trace('example trace message', 'example');
Yii::log('info', CLogger::LEVEL_INFO, 'example');
Yii::log('error', CLogger::LEVEL_ERROR, 'example');
Yii::log('trace', CLogger::LEVEL_TRACE, 'example');
Yii::log('warning', CLogger::LEVEL_WARNING, 'example');
Yii::beginProfile('preg_replace', 'example');
for ($i = 0; $i < 10000; $i++) {
preg_replace('~^[ a-z]+~', '', 'test it');
}
Yii::endProfile('preg_replace', 'example');
echo 'done';
}
示例13: actionView
public function actionView($id)
{
Yii::beginProfile('message_view');
$message = PmbApi::getMessageById($id);
if (!$message) {
throw new CHttpException(404, 'The requested page does not exist.');
}
if ($message->from_user_id != Yii::app()->user->id && $message->to_user_id != Yii::app()->user->id) {
$this->redirect('/messages');
}
$read = PmbApi::markRead(array($id));
$unread = PmbApi::getUnreadInboxCount(Yii::app()->user->id);
$this->render('view', array('message' => $message, 'unread' => $unread, 'id' => $id));
Yii::endProfile('message_view');
}
示例14: init
public function init()
{
parent::init();
if ($this->module) {
// $this->migrateUp();
// $this->loadClassMap();
// $this->loadControllerMap();
// $this->loadViewPathMap();
// $this->loadCustomConfig();
foreach (['loadClassMap', 'loadCustomConfig', 'migrateUp'] as $func) {
\Yii::beginProfile(get_called_class() . '->' . $func, __METHOD__);
$this->{$func}();
\Yii::endProfile(get_called_class() . '->' . $func, __METHOD__);
}
}
}
示例15: init
public function init()
{
Yii::beginProfile(__CLASS__);
$path = Yii::getPathOfAlias('app.widgets.NewsSocials.libs.share42');
$assetsUrl = app()->getAssetManager()->publish($path, FALSE, -1, YII_DEBUG);
js($assetsUrl . '/share42.js', CClientScript::POS_END);
// Обрезаю description
if (!empty($this->params['data-description'])) {
$this->params['data-description'] = strip_tags($this->params['data-description']);
if (mb_strlen($this->params['data-description']) > $this->charLimit) {
$this->params['data-description'] = characterLimiter($this->params['data-description'], $this->charLimit, ' ...');
}
}
echo CHtml::openTag('div', $this->params + array('class' => 'share42init')) . CHtml::closeTag('div');
Yii::endProfile(__CLASS__);
}