当前位置: 首页>>代码示例>>PHP>>正文


PHP Yii::beginProfile方法代码示例

本文整理汇总了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());
 }
开发者ID:skeeks-cms,项目名称:cms,代码行数:7,代码来源:Component.php

示例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');
 }
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:34,代码来源:JsonRpcAction.php

示例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);
 }
开发者ID:frogoscar,项目名称:mobcent-discuz,代码行数:25,代码来源:CacheController.php

示例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');
 }
开发者ID:aekkapun,项目名称:yii2-mylib,代码行数:33,代码来源:Configuration.php

示例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__);
 }
开发者ID:tquant,项目名称:yii2-asset-combiner,代码行数:29,代码来源:AssetCombinerBehavior.php

示例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;
 }
开发者ID:DevGroup-ru,项目名称:dotplant-monster,代码行数:34,代码来源:DataProviderProcessor.php

示例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;
    }
开发者ID:Liv1020,项目名称:cms,代码行数:33,代码来源:Widget.php

示例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;
 }
开发者ID:Liv1020,项目名称:cms,代码行数:30,代码来源:Menu.php

示例9: runProfilingSampleLoop

 private function runProfilingSampleLoop()
 {
     Yii::beginProfile('dummy method');
     for ($i = 0; $i < 100; $i++) {
         $a = 1;
     }
     Yii::endProfile('dummy method');
 }
开发者ID:shiki,项目名称:yii-firephp,代码行数:8,代码来源:SiteController.php

示例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;
 }
开发者ID:DavBfr,项目名称:BlogMVC,代码行数:16,代码来源:Comment.php

示例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;
 }
开发者ID:nizsheanez,项目名称:yii2-json-rpc,代码行数:14,代码来源:Action.php

示例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');
             }
         });
     }
 }
开发者ID:skeeks-semenov,项目名称:yii2-external-links,代码行数:56,代码来源:ExternalLinksComponent.php

示例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');
 }
开发者ID:romeo14,项目名称:wallfeet,代码行数:13,代码来源:WishlistController.php

示例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';
 }
开发者ID:moohwaan,项目名称:yii-application-cookbook-2nd-edition-code,代码行数:14,代码来源:LogController.php

示例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;
 }
开发者ID:sam-it,项目名称:yii1-datatables,代码行数:49,代码来源:DataTable.php


注:本文中的Yii::beginProfile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。