本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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;
}
示例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();
}
示例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();
}
示例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;
}
示例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();
}
示例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);
}
}
示例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;
}
示例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
}
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}