本文整理汇总了PHP中sfTimerManager::clearTimers方法的典型用法代码示例。如果您正苦于以下问题:PHP sfTimerManager::clearTimers方法的具体用法?PHP sfTimerManager::clearTimers怎么用?PHP sfTimerManager::clearTimers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfTimerManager
的用法示例。
在下文中一共展示了sfTimerManager::clearTimers方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: 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();
}
示例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);
//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();
}
示例4: lime_test
<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require_once __DIR__ . '/../../bootstrap/unit.php';
$t = new lime_test(6);
$t->diag('sfTimer starting and stopping');
$timer = new sfTimer();
$timer->addTime();
sleep(1);
$timer->addTime();
$t->is($timer->getCalls(), 2, '->getCalls() returns the amount of addTime() calls');
$t->ok($timer->getElapsedTime() > 0, '->getElapsedTime() returns a value greater than zero. No precision is tested by the unit test to avoid false alarms');
$t->diag('sfTimerManager');
$timerA = sfTimerManager::getTimer('timerA');
$timerB = sfTimerManager::getTimer('timerB');
$t->isa_ok($timerA, 'sfTimer', '::getTimer() returns an sfTimer instance');
$timers = sfTimerManager::getTimers();
$t->is(count($timers), 2, '::getTimers() returns an array with the timers created by the timer manager');
$t->is($timers['timerA'], $timerA, '::getTimers() returns an array with keys being the timer name');
sfTimerManager::clearTimers();
$t->is(count(sfTimerManager::getTimers()), 0, '::clearTimers() empties the list of the timer instances');