public static function initForTests() { Kwf_Session::start(); Kwf_Util_MemoryLimit::set(512); Kwf_Component_Data_Root::setComponentClass(false); Zend_Registry::set('db', Kwf_Test::getTestDb()); set_time_limit(0); Kwf_Benchmark::disable(); }
public function testRequests() { Kwf_Benchmark::enable(); Kwf_Benchmark::reset(); $this->_proxyModel->getRows(); $this->assertEquals(1, Kwf_Benchmark::getCounterValue('mirror sync')); $this->_proxyModel->getRow(3); $this->assertEquals(1, Kwf_Benchmark::getCounterValue('mirror sync')); $this->_proxyModel->getIds(); $this->assertEquals(1, Kwf_Benchmark::getCounterValue('mirror sync')); $this->_proxyModel->countRows(); $this->assertEquals(1, Kwf_Benchmark::getCounterValue('mirror sync')); Kwf_Benchmark::disable(); }
public function testProcessInputPerformance() { Kwf_Benchmark::enable(); Kwf_Benchmark::reset(); $p = $this->_root->getChildComponent('_table1'); $process = $p->getRecursiveChildComponents(array('page' => false, 'flags' => array('processInput' => true))); $process = array_values($process); $this->assertEquals(1, count($process)); $this->assertEquals('root_table1-1-1', $process[0]->componentId); //Kwf_Benchmark::output(); //root gibts schon //root_table, root_table-1, root_table-1-1 $this->assertEquals(3, Kwf_Benchmark::getCounterValue('componentDatas')); Kwf_Benchmark::disable(); }
public function testNoSyncWhenOnlySavedToSibling() { sleep(2); Kwf_Benchmark::enable(); Kwf_Benchmark::reset(); $mirror = new Kwf_Model_MirrorCache_MirrorCacheModel(); $r = $mirror->getRow(1); $r->siblingcol = 'sib val 1'; $r->save(); $r = $mirror->getRow(1); $r->firstname = 'Herbert'; $r->save(); $this->assertEquals(1, Kwf_Benchmark::getCounterValue('mirror sync')); Kwf_Benchmark::reset(); Kwf_Benchmark::disable(); $this->assertEquals('sib val 1', $mirror->getRow(1)->siblingcol); }
public function tearDown() { parent::tearDown(); Kwf_Benchmark::disable(); }
public function testPerformance() { Kwf_Benchmark::enable(); Kwf_Benchmark::reset(); $m = new Kwf_Util_Model_Amazon_Products(); $select = $m->select(); $select->whereEquals('Keywords', 'php'); $select->whereEquals('SearchIndex', 'Books'); $select->limit(10); $m->getRows($select); $this->assertEquals(1, Kwf_Benchmark::getCounterValue('Service Amazon request')); $m->countRows($select); $this->assertEquals(1, Kwf_Benchmark::getCounterValue('Service Amazon request')); $select->limit(10, 10); $m->countRows($select); $this->assertEquals(1, Kwf_Benchmark::getCounterValue('Service Amazon request')); sleep(1); Kwf_Benchmark::reset(); $m = new Kwf_Util_Model_Amazon_Products(); $select->limit(10, 10); $m->getRows($select); $this->assertEquals(1, Kwf_Benchmark::getCounterValue('Service Amazon request')); $select->limit(10, 0); $m->countRows($select); $this->assertEquals(1, Kwf_Benchmark::getCounterValue('Service Amazon request')); Kwf_Benchmark::disable(); }
public function testCreate() { sleep(2); Kwf_Benchmark::enable(); Kwf_Benchmark::reset(); // sync with another instance $this->_getNewModel()->synchronize(); $this->assertEquals(1, Kwf_Benchmark::getCounterValue('mirror sync')); Kwf_Benchmark::reset(); // add a row to source model $source = $this->_sourceModel->createRow(array('id' => 4, 'firstname' => 'Vier', 'timefield' => date('Y-m-d H:i:s', time() - 5))); $source->save(); $this->assertEquals(null, Kwf_Benchmark::getCounterValue('mirror sync')); $this->assertEquals(null, $this->_proxyModel->getRow(4)); // update a row - at the end the added source row (id=4) must be in proxymodel $r = $this->_proxyModel->createRow(); $r->firstname = 'Nadine'; $r->timefield = date("Y-m-d H:i:s"); $this->assertEquals(null, Kwf_Benchmark::getCounterValue('mirror sync')); $r->save(); $this->assertEquals(1, Kwf_Benchmark::getCounterValue('mirror sync')); $this->assertEquals('Vier', $this->_proxyModel->getRow(4)->firstname); $this->assertEquals('Vier', $this->_mirrorModel->getRow(4)->firstname); $this->assertEquals(5, $r->id); $this->assertEquals(5, $this->_mirrorModel->getRow(5)->id); $this->assertEquals(5, $this->_sourceModel->getRow(5)->id); $this->assertEquals('Nadine', $this->_sourceModel->getRow(5)->firstname); Kwf_Benchmark::disable(); }