/** * @group large */ public function testNodeEnclose4() { #fwrite(STDOUT, 'testNodeEnclose4'.PHP_EOL); $runName = uniqid('', true); $fileName = 'testfile_table_table_' . date('Ymd_His') . '_' . $runName . '.yml'; $NODES = 100; Bucket::$SIZE_MAX = 20; $localNode = new Node(); $localNode->setIdHexStr('12000001-2002-4004-8008-100000000001'); $table = new Table('test_data/' . $fileName); $table->setDatadirBasePath('test_data'); $table->setLocalNode($localNode); $table->load(); $nodeNoBegin = 100000000002; $nodeNoEnd = $nodeNoBegin + $NODES; for ($nodeNo = $nodeNoBegin; $nodeNo < $nodeNoEnd; $nodeNo++) { #fwrite(STDOUT, __METHOD__.' node setup: '.$nodeNo.''.PHP_EOL); timeStop('node setup ' . $nodeNo); $node = new Node(); $node->setIdHexStr('12000001-2002-4004-8008-' . $nodeNo); $table->nodeEnclose($node); } fwrite(STDOUT, 'save' . PHP_EOL); $table->save(); $nodeNum = $table->getNodesNum(); fwrite(STDOUT, 'nodes: ' . $nodeNum . '' . PHP_EOL); #$this->assertEquals(160, $nodeNum); $this->assertTrue(true); $finder = new Finder(); $files = $finder->in('test_data')->depth(0)->name('node_*.yml')->files(); #$this->assertEquals(160, count($files)); $this->clean(); }
<?php /* This is a tool to measure how long the execution time is of a piece of code. It works like this:*/ /* Put this in a script you always include in your code */ $times = array(); $timesStopped = array(); function timeStart($name) { $time = explode(" ", microtime()); $time = $time[1] + $time[0]; global $times; $times[$name] = $time; return $time; } function timeStop($name) { $time = explode(" ", microtime()); $time = $time[1] + $time[0]; global $times, $timesStopped; $timesStopped[$name] = round($time - $times[$name], 4); return $timesStopped[$name]; } /* Do this with your code */ timeStart("getting post from database"); mysql_query("SELECT title, text, author FROM posts WHERE id=" . mysql_real_escape_string($_GET['post_id'])); timeStop("getting post from database"); /* Put this on the end of your code, the executed times will be displayed in seconds */ print_r($timesStopped);