當前位置: 首頁>>代碼示例>>PHP>>正文


PHP sfTimerManager::getTimer方法代碼示例

本文整理匯總了PHP中sfTimerManager::getTimer方法的典型用法代碼示例。如果您正苦於以下問題:PHP sfTimerManager::getTimer方法的具體用法?PHP sfTimerManager::getTimer怎麽用?PHP sfTimerManager::getTimer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sfTimerManager的用法示例。


在下文中一共展示了sfTimerManager::getTimer方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: execute

 /**
  * Executes the filter
  */
 public function execute($filterChain)
 {
     $filterChain->execute();
     $response = $this->getContext()->getResponse();
     $request = $this->getContext()->getRequest();
     $controller = $this->getContext()->getController();
     // don't highlight:
     // * for XHR requests
     // * if 304
     // * if not rendering to the client
     // * if HTTP headers only
     if ($request->isXmlHttpRequest() || strpos($response->getContentType(), 'html') === false || $response->getStatusCode() == 304 || $controller->getRenderMode() != sfView::RENDER_CLIENT || $response->isHeaderOnly()) {
         return;
     }
     $timer = sfTimerManager::getTimer('Highlight Filter');
     try {
         $this->highlight();
     } catch (sfLuceneHighlighterException $e) {
         $timer->addTime();
         $this->getContext()->getEventDispatcher()->notify(new sfEvent($this, 'application.log', array($e->getMessage(), 'priority' => sfLogger::WARNING)));
         if ($e instanceof sfLuceneHighlighterXMLException) {
             $errors = $e->getProblems();
             $errors['priority'] = sfLogger::ERR;
             $this->getContext()->getEventDispatcher()->notify(new sfEvent($this, 'application.log', $errors));
         }
     } catch (Exception $e) {
         $timer->addTime();
         throw $e;
     }
     $timer->addTime();
 }
開發者ID:rande,項目名稱:sfSolrPlugin,代碼行數:34,代碼來源:sfLuceneHighlightFilter.class.php

示例2: execute

 public function execute($filterChain)
 {
     $filterChain->execute();
     $response = $this->getContext()->getResponse();
     $request = $this->getContext()->getRequest();
     $controller = $this->getContext()->getController();
     // don't highlight:
     // * for XHR requests
     // * if 304
     // * if not rendering to the client
     // * if HTTP headers only
     if ($request->isXmlHttpRequest() || strpos($response->getContentType(), 'html') === false || $response->getStatusCode() == 304 || $controller->getRenderMode() != sfView::RENDER_CLIENT || $response->isHeaderOnly()) {
         return;
     }
     $timer = sfTimerManager::getTimer('Highlight Filter');
     try {
         if (!$this->highlight()) {
             $this->removeNotice();
         }
     } catch (sfSolrHighlighterException $e) {
         sfLogger::getInstance()->err('{sfSolrHighlightFilter} silently ignoring exception: ' . $e->getMessage());
         if ($this->testMode) {
             $timer->addTime();
             throw $e;
         }
     } catch (Exception $e) {
         $timer->addTime();
         throw $e;
     }
     $timer->addTime();
 }
開發者ID:valerio-bozzolan,項目名稱:openparlamento,代碼行數:31,代碼來源:sfSolrHighlightFilter.class.php

示例3: execute

 protected function execute($arguments = array(), $options = array())
 {
     if (!$this->safeToRun()) {
         print "Process already running!\n";
         die;
     }
     $timer = sfTimerManager::getTimer('execute');
     $databaseManager = new sfDatabaseManager($this->configuration);
     $databaseManager->initialize($this->configuration);
     //set up index
     $index = EntityTable::getLuceneIndex();
     //delete deleted entities
     $q = LsDoctrineQuery::create()->from('Entity e')->where('e.is_deleted = ?', true)->setHydrationMode(Doctrine::HYDRATE_ARRAY);
     foreach ($q->execute() as $entity) {
         if ($hits = $index->find('key:' . $entity['id'])) {
             if ($options['debug_mode']) {
                 printf("Deleting index for Entity %s\n", $entity['id']);
             }
             foreach ($hits as $hit) {
                 $index->delete($hit->id);
             }
         }
     }
     printf("Memory used: %s\n", LsNumber::makeBytesReadable(memory_get_usage()));
     printf("Index size: %s\n", $index->count());
     $timer->addTime();
     printf("Run time: %s\n", $timer->getElapsedTime());
     sfTimerManager::clearTimers();
 }
開發者ID:silky,項目名稱:littlesis,代碼行數:29,代碼來源:CleanSearchIndexTask.class.php

示例4: render

 /**
  * Renders the presentation.
  *
  * @return string Current template content
  */
 public function render()
 {
     if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) {
         $timer = sfTimerManager::getTimer(sprintf('Partial "%s/%s"', $this->moduleName, $this->actionName));
     }
     if (sfConfig::get('sf_cache')) {
         $viewCache = $this->context->getViewCacheManager();
         $viewCache->registerConfiguration($this->moduleName);
         $cacheKey = $viewCache->computeCacheKey($this->partialVars);
         if ($retval = $viewCache->getPartialCache($this->moduleName, $this->actionName, $cacheKey)) {
             return $retval;
         } else {
             $mainResponse = $this->context->getResponse();
             $responseClass = get_class($mainResponse);
             $this->context->setResponse($response = new $responseClass($this->context->getEventDispatcher(), $mainResponse->getOptions()));
         }
     }
     // execute pre-render check
     $this->preRenderCheck();
     $this->getAttributeHolder()->set('sf_type', 'partial');
     // render template
     $retval = $this->renderFile($this->getDirectory() . '/' . $this->getTemplate());
     if (sfConfig::get('sf_cache')) {
         $retval = $viewCache->setPartialCache($this->moduleName, $this->actionName, $cacheKey, $retval);
         $this->context->setResponse($mainResponse);
         $mainResponse->merge($response);
     }
     if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) {
         $timer->addTime();
     }
     return $retval;
 }
開發者ID:ajith24,項目名稱:ajithworld,代碼行數:37,代碼來源:sfPartialView.class.php

示例5: findAndCompile

 /**
  * Listens to the routing.load_configuration event. Finds & compiles LESS files to CSS
  *
  * @param   sfEvent $event  an sfEvent instance
  */
 public static function findAndCompile(sfEvent $event)
 {
     // Start compilation timer for debug info
     $timer = sfTimerManager::getTimer('Less compilation');
     // Create new helper object & compile LESS stylesheets with it
     $less = new sfLESS();
     foreach ($less->findLessFiles() as $lessFile) {
         $less->compile($lessFile);
     }
     // Stop timer
     $timer->addTime();
 }
開發者ID:xfifix,項目名稱:Jenkins-Khan,代碼行數:17,代碼來源:sfLESSListeners.php

示例6: compile

 /**
  * Compile the source files and fix permissions
  *
  * @param string $in      Input directory containing sass files
  * @param string $out     Output directory where to write the css files
  * @param string $cache   Cache folder (null if cache is not used)
  * @param array  $params  Sass compiler parameters
  */
 public function compile($in, $out, $cache, array $params = array())
 {
     $timer = sfTimerManager::getTimer('Sass compilation');
     $this->createFolderIfNeeded($out);
     if (!empty($cache)) {
         $this->createFolderIfNeeded($cache);
     }
     $this->driver->compile($in, $out, $params);
     $this->fixPermissions($out);
     if (!empty($cache)) {
         $this->fixPermissions($cache);
     }
     $timer->addTime();
 }
開發者ID:vicb,項目名稱:sfSassyCssPlugin,代碼行數:22,代碼來源:sfSassCompilerBase.class.php

示例7: render

 /**
  * Renders the presentation.
  *
  * @return string Current template content
  */
 public function render()
 {
     if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) {
         $timer = sfTimerManager::getTimer(sprintf('Partial "%s/%s"', $this->moduleName, $this->actionName));
     }
     if ($retval = $this->getCache()) {
         return $retval;
     } else {
         if ($this->checkCache) {
             $mainResponse = $this->context->getResponse();
             $responseClass = get_class($mainResponse);
             $this->context->setResponse($response = new $responseClass($this->context->getEventDispatcher(), array_merge($mainResponse->getOptions(), array('content_type' => $mainResponse->getContentType()))));
         }
     }
     try {
         // PHP FALLBACK
         try {
             // execute pre-render check
             $this->preRenderCheck();
         } catch (sfRenderException $e) {
             if (null === $this->template) {
                 throw new sfRenderException('A template has not been set.');
             }
             $view = new sfPartialView($this->context, $this->moduleName, $this->actionName, $this->viewName);
             return $view->render();
         } catch (Exception $e) {
             throw $e;
         }
         $this->getAttributeHolder()->set('sf_type', 'partial');
         // render template
         $retval = $this->renderFile($this->getDirectory(), $this->getTemplate());
     } catch (Exception $e) {
         if ($this->checkCache) {
             $this->context->setResponse($mainResponse);
             $mainResponse->merge($response);
         }
         throw $e;
     }
     if ($this->checkCache) {
         $retval = $this->viewCache->setPartialCache($this->moduleName, $this->actionName, $this->cacheKey, $retval);
         $this->context->setResponse($mainResponse);
         $mainResponse->merge($response);
     }
     if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) {
         $timer->addTime();
     }
     return $retval;
 }
開發者ID:pycmam,項目名稱:sfSmarty3Plugin,代碼行數:53,代碼來源:sfSmartyPartialView.php

示例8: execute

 protected function execute($arguments = array(), $options = array())
 {
     if (!$this->safeToRun()) {
         print "Process already running!\n";
         die;
     }
     $timer = sfTimerManager::getTimer('execute');
     //get index and optimize
     $index = EntityTable::getLuceneIndex();
     $index->optimize();
     printf("Memory used: %s\n", LsNumber::makeBytesReadable(memory_get_usage()));
     printf("Index size: %s\n", $index->count());
     $timer->addTime();
     printf("Run time: %s\n", $timer->getElapsedTime());
     sfTimerManager::clearTimers();
 }
開發者ID:silky,項目名稱:littlesis,代碼行數:16,代碼來源:OptimizeSearchIndexTask.class.php

示例9: execute

 /**
  * Executes this filter.
  *
  * @param sfFilterChain $filterChain The filter chain
  *
  * @throws <b>sfInitializeException</b> If an error occurs during view initialization.
  * @throws <b>sfViewException</b>       If an error occurs while executing the view.
  */
 public function execute($filterChain)
 {
     // get the current action instance
     $actionInstance = $this->context->getController()->getActionStack()->getLastEntry()->getActionInstance();
     // execute the action, execute and render the view
     if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) {
         $timer = sfTimerManager::getTimer(sprintf('Action "%s/%s"', $actionInstance->getModuleName(), $actionInstance->getActionName()));
         $viewName = $this->handleAction($filterChain, $actionInstance);
         $timer->addTime();
         $timer = sfTimerManager::getTimer(sprintf('View "%s" for "%s/%s"', $viewName, $actionInstance->getModuleName(), $actionInstance->getActionName()));
         $this->handleView($filterChain, $actionInstance, $viewName);
         $timer->addTime();
     } else {
         $viewName = $this->handleAction($filterChain, $actionInstance);
         $this->handleView($filterChain, $actionInstance, $viewName);
     }
 }
開發者ID:bigcalm,項目名稱:urlcatcher,代碼行數:25,代碼來源:sfExecutionFilter.class.php

示例10: render

 /**
  * Renders the presentation.
  *
  * @param array Template attributes
  *
  * @return string Current template content
  */
 public function render($templateVars = array())
 {
     if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) {
         $timer = sfTimerManager::getTimer(sprintf('Partial "%s/%s"', $this->moduleName, $this->actionName));
     }
     // execute pre-render check
     $this->preRenderCheck();
     // assigns some variables to the template
     $this->attributeHolder->add($this->getGlobalVars());
     $this->attributeHolder->add($templateVars);
     // render template
     $retval = $this->renderFile($this->getDirectory() . '/' . $this->getTemplate());
     if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) {
         $timer->addTime();
     }
     return $retval;
 }
開發者ID:Daniel-Marynicz,項目名稱:symfony1-legacy,代碼行數:24,代碼來源:sfPartialView.class.php

示例11: init

 private function init()
 {
     if (sfContext::getInstance()->has('profiler')) {
         $timer = sfTimerManager::getTimer('afRead');
         // this time will be stopeed inside XmlParser constructor
     }
     $parser = new XmlParser();
     $this->type = $parser->getType();
     $this->layout = $parser->getLayout();
     if (method_exists($this->layout, 'beforeEnd')) {
         $this->layout->beforeEnd();
     }
     if (sfContext::getInstance()->has('profiler')) {
         $timer = sfTimerManager::getTimer('afRender');
         $timer->addTime();
         // this one closes afRender timer that was started inside XmlParser constructor
     }
 }
開發者ID:cbsistem,項目名稱:appflower_engine,代碼行數:18,代碼來源:afExtjsAjaxLoadWidgets.php

示例12: render

 /**
  * Renders the presentation.
  *
  * @return string Current template content
  */
 public function render()
 {
     if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) {
         $timer = sfTimerManager::getTimer(sprintf('Partial "%s/%s"', $this->moduleName, $this->actionName));
     }
     if ($retval = $this->getCache()) {
         if ($this->isFlavorPartial(ncFlavorFlavors::getModulePath($module_name) . '/templates', $this->getTemplate())) {
             $retval = $this->renderFile($this->getFlavorDirectory($this->getModuleName(), $this->getTemplate()) . '/' . $this->getTemplate());
         }
         return $retval;
     } else {
         if ($this->checkCache) {
             $mainResponse = $this->context->getResponse();
             $responseClass = get_class($mainResponse);
             $this->context->setResponse($response = new $responseClass($this->context->getEventDispatcher(), array_merge($mainResponse->getOptions(), array('content_type' => $mainResponse->getContentType()))));
         }
     }
     try {
         // execute pre-render check
         $this->preRenderCheck();
         $this->getAttributeHolder()->set('sf_type', 'partial');
         // render template
         $retval = $this->renderFile($this->getFlavorDirectory($this->getModuleName(), $this->getTemplate()) . '/' . $this->getTemplate());
     } catch (Exception $e) {
         if ($this->checkCache) {
             $this->context->setResponse($mainResponse);
             $mainResponse->merge($response);
         }
         throw $e;
     }
     if ($this->checkCache) {
         if ($this->isFlavorPartial(ncFlavorFlavors::getModulePath($module_name) . '/templates', $this->getTemplate())) {
             $retval = $this->renderFile($this->getFlavorDirectory($this->getModuleName(), $this->getTemplate()) . '/' . $this->getTemplate());
         } else {
             $retval = $this->viewCache->setPartialCache($this->moduleName, $this->actionName, $this->cacheKey, $retval);
         }
         $this->context->setResponse($mainResponse);
         $mainResponse->merge($response);
     }
     if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) {
         $timer->addTime();
     }
     return $retval;
 }
開發者ID:nvidela,項目名稱:kimkelen,代碼行數:49,代碼來源:ncFlavorPartialView.class.php

示例13: render

 /**
  * Renders the presentation.
  *
  * @return string Current template content
  */
 public function render()
 {
     if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) {
         $timer = sfTimerManager::getTimer(sprintf('Partial "%s/%s"', $this->moduleName, $this->actionName));
     }
     if ($retval = $this->getCache()) {
         return $retval;
     }
     if ($this->checkCache) {
         $mainResponse = $this->context->getResponse();
         $responseClass = get_class($mainResponse);
         $response = new $responseClass($this->context->getEventDispatcher(), $mainResponse->getOptions());
         // the inner response has access to different properties, depending on whether it is marked as contextual in cache.yml
         if ($this->viewCache->isContextual($this->viewCache->getPartialUri($this->moduleName, $this->actionName, $this->cacheKey))) {
             $response->copyProperties($mainResponse);
         } else {
             $response->setContentType($mainResponse->getContentType());
         }
         $this->context->setResponse($response);
     }
     try {
         // execute pre-render check
         $this->preRenderCheck();
         $this->getAttributeHolder()->set('sf_type', 'partial');
         // render template
         $retval = $this->renderFile($this->getDirectory() . '/' . $this->getTemplate());
     } catch (Exception $e) {
         if ($this->checkCache) {
             $this->context->setResponse($mainResponse);
             $mainResponse->merge($response);
         }
         throw $e;
     }
     if ($this->checkCache) {
         $retval = $this->viewCache->setPartialCache($this->moduleName, $this->actionName, $this->cacheKey, $retval);
         $this->context->setResponse($mainResponse);
         $mainResponse->merge($response);
     }
     if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) {
         $timer->addTime();
     }
     return $retval;
 }
開發者ID:sensorsix,項目名稱:app,代碼行數:48,代碼來源:sfPartialView.class.php

示例14: execute

 protected function execute($arguments = array(), $options = array())
 {
     if (!$this->safeToRun()) {
         print "Process already running!\n";
         die;
     }
     $timer = sfTimerManager::getTimer('execute');
     $databaseManager = new sfDatabaseManager($this->configuration);
     $databaseManager->initialize($this->configuration);
     //get id of last-indexed entity
     $index = EntityTable::getLuceneIndex($options['index_file']);
     $index->setMergeFactor(200);
     $index->setMaxBufferedDocs(20);
     if ($count = $index->count()) {
         if (!($lastDoc = $index->getDocument($count - 1))) {
             throw new Exception("Can't find last document in index");
         }
         $maxEntityId = $lastDoc->key;
     } else {
         $maxEntityId = 0;
     }
     //find non-deleted entities with greater IDs
     $q = LsDoctrineQuery::create()->from('Entity e')->leftJoin('e.Alias a')->where('e.id > ? AND e.is_deleted = ?', array($maxEntityId, false))->andWhere('a.context IS NULL')->offset($options['offset'])->limit($options['limit'])->orderBy('e.id ASC');
     //index entities
     $optimize = 0;
     foreach ($q->fetchArray() as $entity) {
         if (EntityTable::updateLuceneIndex($entity, $index, $batchMode = true)) {
             if ($options['debug_mode']) {
                 printf("Indexed entity with ID %s\n", $entity['id']);
             }
         } else {
             if ($options['debug_mode']) {
                 printf("Skipped entity with ID %s\n", $entity['id']);
             }
         }
     }
     printf("Memory used: %s\n", LsNumber::makeBytesReadable(memory_get_usage()));
     printf("Index size: %s\n", $index->count());
     $timer->addTime();
     printf("Run time: %s\n", $timer->getElapsedTime());
     sfTimerManager::clearTimers();
 }
開發者ID:silky,項目名稱:littlesis,代碼行數:42,代碼來源:GenerateSearchIndexTask.class.php

示例15: execute

 /**
  * Executes this filter.
  *
  * @param sfFilterChain The filter chain
  *
  * @throws <b>sfInitializeException</b> If an error occurs during view initialization.
  * @throws <b>sfViewException</b>       If an error occurs while executing the view.
  */
 public function execute($filterChain)
 {
     // get the current action instance
     $actionInstance = $this->context->getController()->getActionStack()->getLastEntry()->getActionInstance();
     // validate and execute the action
     if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) {
         $timer = sfTimerManager::getTimer(sprintf('Action "%s/%s"', $actionInstance->getModuleName(), $actionInstance->getActionName()));
     }
     $viewName = $this->handleAction($filterChain, $actionInstance);
     if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) {
         $timer->addTime();
     }
     // execute and render the view
     if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) {
         $timer = sfTimerManager::getTimer(sprintf('View "%s" for "%s/%s"', $viewName, $actionInstance->getModuleName(), $actionInstance->getActionName()));
     }
     $this->handleView($filterChain, $actionInstance, $viewName);
     if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) {
         $timer->addTime();
     }
     // execute the filter chain (needed if fill-in filter is activated by the validation system)
     $filterChain->execute();
 }
開發者ID:WIZARDISHUNGRY,項目名稱:symfony,代碼行數:31,代碼來源:sfValidationExecutionFilter.class.php


注:本文中的sfTimerManager::getTimer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。