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


PHP sfTimerManager类代码示例

本文整理汇总了PHP中sfTimerManager的典型用法代码示例。如果您正苦于以下问题:PHP sfTimerManager类的具体用法?PHP sfTimerManager怎么用?PHP sfTimerManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了sfTimerManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: filterResponseContent

 /**
  * Listens to the response.filter_content event.
  *
  * @param  sfEvent $event   The sfEvent instance
  * @param  string  $context The response content
  *
  * @return string  The filtered response content
  */
 public function filterResponseContent(sfEvent $event, $content)
 {
     if (!sfConfig::get('sf_web_debug')) {
         return $content;
     }
     // log timers information
     $messages = array();
     foreach (sfTimerManager::getTimers() as $name => $timer) {
         $messages[] = sprintf('%s %.2f ms (%d)', $name, $timer->getElapsedTime() * 1000, $timer->getCalls());
     }
     $this->dispatcher->notify(new sfEvent($this, 'application.log', $messages));
     // don't add debug toolbar:
     // * for XHR requests
     // * if 304
     // * if not rendering to the client
     // * if HTTP headers only
     $response = $event->getSubject();
     if (!$this->context->has('request') || !$this->context->has('response') || !$this->context->has('controller') || $this->context->getRequest()->isXmlHttpRequest() || strpos($response->getContentType(), 'html') === false || $response->getStatusCode() == 304 || $this->context->getController()->getRenderMode() != sfView::RENDER_CLIENT || $response->isHeaderOnly()) {
         return $content;
     }
     // add needed assets for the web debug toolbar
     $root = $this->context->getRequest()->getRelativeUrlRoot();
     $assets = sprintf('
   <script type="text/javascript" src="%s"></script>
   <link rel="stylesheet" type="text/css" media="screen" href="%s" />', $root . sfConfig::get('sf_web_debug_web_dir') . '/js/main.js', $root . sfConfig::get('sf_web_debug_web_dir') . '/css/main.css');
     $content = str_ireplace('</head>', $assets . '</head>', $content);
     // add web debug information to response content
     $webDebugContent = $this->webDebug->getResults();
     $count = 0;
     $content = str_ireplace('</body>', $webDebugContent . '</body>', $content, $count);
     if (!$count) {
         $content .= $webDebugContent;
     }
     return $content;
 }
开发者ID:ajith24,项目名称:ajithworld,代码行数:43,代码来源:sfWebDebugLogger.class.php

示例2: 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

示例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: 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

示例6: getPanelContent

 public function getPanelContent()
 {
     if (sfTimerManager::getTimers()) {
         $totalTime = $this->getTotalTime();
         $panel = '<table class="sfWebDebugLogs" style="width: 300px"><tr><th>type</th><th>calls</th><th>time (ms)</th><th>time (%)</th></tr>';
         foreach (sfTimerManager::getTimers() as $name => $timer) {
             $panel .= sprintf('<tr><td class="sfWebDebugLogType">%s</td><td class="sfWebDebugLogNumber" style="text-align: right">%d</td><td style="text-align: right">%.2f</td><td style="text-align: right">%d</td></tr>', $name, $timer->getCalls(), $timer->getElapsedTime() * 1000, $totalTime ? $timer->getElapsedTime() * 1000 * 100 / $totalTime : 'N/A');
         }
         $panel .= '</table>';
         return $panel;
     }
 }
开发者ID:hunde,项目名称:bsc,代码行数:12,代码来源:sfWebDebugPanelTimer.class.php

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: getPanelContent

 public function getPanelContent()
 {
     $panel = array();
     $timers = sfTimerManager::getTimers();
     if (sfConfig::get('sf_debug') && $timers) {
         $totalTime = $this->getTotalTime();
         $timer_nb = 1;
         foreach ($timers as $name => $timer) {
             array_push($panel, array('number' => $timer_nb, 'name' => $name, 'calls' => $timer->getCalls(), 'time' => $timer->getElapsedTime() * 1000, 'percent' => $totalTime ? $timer->getElapsedTime() * 1000 * 100 / $totalTime : 'N/A'));
             $timer_nb++;
         }
         $panel['total'] = 'Total time: ' . $this->getTotalTime() . ' ms';
     } else {
         $panel['total'] = 'No info available';
     }
     return $panel;
 }
开发者ID:googlecode-mirror,项目名称:orso,代码行数:17,代码来源:fsWebDebugPanelTimer.class.php

示例12: 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

示例13: 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

示例14: 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

示例15: 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


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