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();
 }
 public function indexAction()
 {
     Kwf_Benchmark::enable();
     Kwf_Benchmark::reset();
     self::setup();
     self::$proxyModel->countRows();
     echo (int) Kwf_Benchmark::getCounterValue('mirror sync');
     exit;
 }
Exemplo n.º 3
0
 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();
 }
Exemplo n.º 4
0
 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);
 }
Exemplo n.º 6
0
 public function testCached()
 {
     Kwf_Benchmark::enable();
     Kwf_Benchmark::reset();
     $d = Kwf_Registry::get('testDomain');
     $c = $this->_root->getPageByUrl("http://{$d}/foo", null);
     //uncached
     $this->assertEquals('1', $c->componentId);
     $this->assertEquals(1, Kwf_Benchmark::getCounterValue('componentDatas'));
     $this->assertEquals(0, (int) Kwf_Benchmark::getCounterValue('unserialized componentDatas'));
     Kwf_Component_Data_Root::reset();
     Kwf_Component_Data_Root::setComponentClass('Kwf_Component_Cache_UrlClearCache_Root');
     $this->_root = Kwf_Component_Data_Root::getInstance();
     Kwf_Benchmark::reset();
     $c = $this->_root->getPageByUrl("http://{$d}/foo", null);
     //cached
     $this->assertEquals('1', $c->componentId);
     $this->assertEquals(0, (int) Kwf_Benchmark::getCounterValue('componentDatas'));
     $this->assertEquals(1, Kwf_Benchmark::getCounterValue('unserialized componentDatas'));
 }
 public function testSyncWithCli()
 {
     Kwf_Benchmark::enable();
     Kwf_Benchmark::reset();
     Kwf_Model_MirrorCache_TestController::setup();
     Kwf_Model_MirrorCache_TestController::$proxyModel->synchronize(Kwf_Model_MirrorCache::SYNC_ONCE);
     $this->assertEquals(1, (int) Kwf_Benchmark::getCounterValue('mirror sync'));
     $url = 'http://' . Kwf_Registry::get('testDomain') . '/kwf/test/kwf_model_mirror-cache_test';
     $this->assertEquals(0, file_get_contents($url));
     sleep(6);
     //sync delay ist 5 sec
     $this->assertEquals(1, file_get_contents($url));
     $this->assertEquals(0, file_get_contents($url));
     Kwf_Benchmark::reset();
     Kwf_Model_MirrorCache_TestController::$proxyModel->countRows();
     $this->assertEquals(0, (int) Kwf_Benchmark::getCounterValue('mirror sync'));
     sleep(6);
     //sync delay ist 5 sec
     Kwf_Benchmark::reset();
     Kwf_Model_MirrorCache_TestController::$proxyModel->synchronize(Kwf_Model_MirrorCache::SYNC_ALWAYS);
     $this->assertEquals(1, (int) Kwf_Benchmark::getCounterValue('mirror sync'));
     $this->assertEquals(0, file_get_contents($url));
 }
Exemplo n.º 8
0
 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();
 }