本文整理汇总了PHP中Yii::beginProfile方法的典型用法代码示例。如果您正苦于以下问题:PHP Yii::beginProfile方法的具体用法?PHP Yii::beginProfile怎么用?PHP Yii::beginProfile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Yii
的用法示例。
在下文中一共展示了Yii::beginProfile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
$this->defaultAttributes = $this->attributes;
\Yii::beginProfile("Init: " . $this->className());
$this->initSettings();
\Yii::endProfile("Init: " . $this->className());
}
示例2: 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');
}
示例3: 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);
}
示例4: load
public function load($filename)
{
if (!is_readable($filename)) {
throw new \yii\base\InvalidValueException('cannot read config file at this location: ' . $filename);
}
$this->config = Json::decode(file_get_contents($filename), false);
\Yii::beginProfile('reflection', 'config');
//
// silently injects newly introduced option into current config from default config
//
$def_config = $this->getDefaultCfg();
$rf1 = new \ReflectionObject($def_config);
/* @var $p_base \ReflectionProperty */
foreach ($rf1->getProperties() as $p_base) {
// lvl-1: system, book ...
$lvl1 = $p_base->name;
if (empty($this->config->{$lvl1})) {
$this->config->{$lvl1} = $def_config->{$lvl1};
continue;
}
$rf2 = new \ReflectionObject($def_config->{$p_base->name});
foreach ($rf2->getProperties() as $p_option) {
//lvl-2: system->theme ..
$lvl2 = $p_option->name;
if (empty($this->config->{$lvl1}->{$lvl2})) {
$this->config->{$lvl1}->{$lvl2} = $def_config->{$lvl1}->{$lvl2};
continue;
//reserved. required for lvl-3 if introduced
}
}
}
\Yii::endProfile('reflection', 'config');
}
示例5: 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__);
}
示例6: 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;
}
示例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: 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;
}
示例9: runProfilingSampleLoop
private function runProfilingSampleLoop()
{
Yii::beginProfile('dummy method');
for ($i = 0; $i < 100; $i++) {
$a = 1;
}
Yii::endProfile('dummy method');
}
示例10: 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;
}
示例11: 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;
}
示例12: bootstrap
/**
* @param \yii\web\Application $app
*/
public function bootstrap($app)
{
if ($app instanceof Application) {
$app->response->on(Response::EVENT_AFTER_PREPARE, function (Event $e) use($app) {
/**
* @var $response Response
*/
$response = $e->sender;
$this->trigger(self::EVENT_BEFORE_PROCESSING);
if ($this->enabled && !$app->request->isAjax && !$app->request->isPjax && $app->response->format == Response::FORMAT_HTML) {
\Yii::beginProfile('ExternalLinks');
$content = $response->content;
$this->initReplaceLinks();
$matches = [];
if (preg_match_all("/<[Aa][\\s]{1}[^>]*[Hh][Rr][Ee][Ff][^=]*=[ '\"\\s]*([^ \"'>\\s#]+)[^>]*>/", $content, $matches)) {
if (isset($matches[1])) {
foreach ($matches[1] as $link) {
//Относительные ссылки пропускать
if (Url::isRelative($link)) {
continue;
}
if ($dataLink = parse_url($link)) {
//Для этого хоста не нужно менять ссылку
$host = ArrayHelper::getValue($dataLink, 'host');
if (in_array($host, $this->noReplaceLinksOnDomains)) {
continue;
}
}
$linkForUrl = $link;
if ($this->enabledB64Encode) {
$linkForUrl = base64_encode($link);
}
$newUrl = Url::to([$this->backendRoute, $this->backendRouteParam => $linkForUrl]);
//replacing references only after <body
$bodyPosition = strpos($content, '<body');
$headerContent = substr($content, 0, $bodyPosition);
$bodyContent = substr($content, $bodyPosition, strlen($content));
$resultContent = '';
$replaceUrl = 'href="' . $newUrl . '"';
$bodyContent = str_replace('href="' . $link . '"', $replaceUrl, $bodyContent);
$replaceUrl = 'href=\'' . $newUrl . '\'';
$bodyContent = str_replace('href=\'' . $link . '\'', $replaceUrl, $bodyContent);
$resultContent = $headerContent . $bodyContent;
$content = $resultContent;
}
}
}
$response->content = $content;
\Yii::endProfile('ExternalLinks');
}
});
}
}
示例13: 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');
}
示例14: 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';
}
示例15: createDataArray
protected function createDataArray()
{
\Yii::beginProfile('createDataArray');
$data = [];
Yii::beginProfile('getData');
if (!$this->config['serverSide']) {
$paginator = $this->dataProvider->getPagination();
if ($this->dataProvider instanceof \CActiveDataProvider) {
$this->dataProvider->criteria->order = '';
}
$this->dataProvider->setPagination(false);
$source = $this->dataProvider->getData(true);
$this->dataProvider->setPagination($paginator);
} else {
$source = $this->dataProvider->getData();
}
Yii::endProfile('getData');
Yii::beginProfile('renderCells');
// Get column name map.
$names = array_map([$this, 'getColumnName'], $this->columns);
foreach ($source as $i => $r) {
$row = [];
foreach ($this->columns as $j => $column) {
$name = $names[$j];
$row[$name] = $column->getDataCellContent($i);
}
$metaRow = [];
if ($this->addMetaData !== false) {
Yii::beginProfile('addMetaData');
if (is_callable([$r, 'getKeyString'])) {
$metaRow['data-key'] = call_user_func([$r, 'getKeyString']);
}
if (is_array($this->addMetaData)) {
foreach ($this->addMetaData as $field) {
$metaRow["data-{$field}"] = \CHtml::value($r, $field);
}
}
Yii::endProfile('addMetaData');
}
if (isset($this->rowCssClassExpression)) {
$metaRow['class'] = $this->evaluateExpression($this->rowCssClassExpression, array('row' => $i, 'data' => $r));
}
$row['metaData'] = $metaRow;
$data[] = $row;
}
\Yii::endProfile('renderCells');
\Yii::endProfile('createDataArray');
return $data;
}