本文整理匯總了PHP中DebugKitDebugger::getTimers方法的典型用法代碼示例。如果您正苦於以下問題:PHP DebugKitDebugger::getTimers方法的具體用法?PHP DebugKitDebugger::getTimers怎麽用?PHP DebugKitDebugger::getTimers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DebugKitDebugger
的用法示例。
在下文中一共展示了DebugKitDebugger::getTimers方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __destruct
/**
* destruct method
*
* Allow timer info to be displayed if the code dies or is being debugged before rendering the view
* Cheat and use the debug log class for formatting
*
* @return void
* @access private
*/
function __destruct()
{
$_this =& DebugKitDebugger::getInstance();
if (Configure::read('debug') < 2 || !$_this->__benchmarks) {
return;
}
$timers = array_values(DebugKitDebugger::getTimers());
$end = end($timers);
echo '<table class="cake-sql-log"><tbody>';
echo '<caption>Debug timer info</caption>';
echo '<tr><th>Message</th><th>Start Time (ms)</th><th>End Time (ms)</th><th>Duration (ms)</th></tr>';
$i = 0;
foreach ($timers as $timer) {
$indent = 0;
for ($j = 0; $j < $i; $j++) {
if ($timers[$j]['end'] > $timer['start'] && $timers[$j]['end'] > $timer['end']) {
$indent++;
}
}
$indent = str_repeat(' » ', $indent);
extract($timer);
$start = round($start * 1000, 0);
$end = round($end * 1000, 0);
$time = round($time * 1000, 0);
echo "<tr><td>{$indent}{$message}</td><td>{$start}</td><td>{$end}</td><td>{$time}</td></tr>";
$i++;
}
echo '</tbody></table>';
}
示例2: testSaveTimers
/**
* Test save timers
*
* @return void
*/
public function testSaveTimers()
{
$timers = DebugKitDebugger::getTimers(false);
$this->assertEquals(count($timers), 1);
$this->Article->save(array('user_id' => 1, 'title' => 'test', 'body' => 'test'));
$result = DebugKitDebugger::getTimers(false);
$this->assertEquals(count($result), 2);
}
示例3: testGetTimers
/**
* test getting all the set timers.
*
* @return void
**/
function testGetTimers()
{
DebugKitDebugger::startTimer('test1', 'this is my first test');
DebugKitDebugger::stopTimer('test1');
usleep(50);
DebugKitDebugger::startTimer('test2');
DebugKitDebugger::stopTimer('test2');
$timers = DebugKitDebugger::getTimers();
$this->assertEqual(count($timers), 3);
$this->assertTrue(is_float($timers['test1']['time']));
$this->assertTrue(isset($timers['test1']['message']));
$this->assertTrue(isset($timers['test2']['message']));
}
示例4: testBeforeRedirect
/**
* test that vars are gathered and state is saved on beforeRedirect
*
* @return void
**/
public function testBeforeRedirect() {
$this->_loadController(array(
'panels' => array('test', 'session', 'history'),
));
$configName = 'debug_kit';
$this->Controller->Toolbar->cacheKey = 'toolbar_history';
Cache::delete('toolbar_history', $configName);
DebugKitDebugger::startTimer('controllerAction', 'testing beforeRedirect');
$MockPanel = $this->getMock('DebugPanel');
$MockPanel->expects($this->once())->method('beforeRender');
$this->Controller->Toolbar->panels['test'] = $MockPanel;
$this->Controller->Toolbar->beforeRedirect($this->Controller);
$result = Cache::read('toolbar_history', $configName);
$this->assertTrue(isset($result[0]['session']));
$this->assertTrue(isset($result[0]['test']));
$timers = DebugKitDebugger::getTimers();
$this->assertTrue(isset($timers['controllerAction']));
}
示例5: testRenderTimers
/**
* test rendering and ensure that timers are being set.
*
* @access public
* @return void
*/
function testRenderTimers()
{
$this->Controller->viewPath = 'posts';
$this->Controller->action = 'index';
$this->Controller->params = array('action' => 'index', 'controller' => 'posts', 'plugin' => null, 'url' => array('url' => 'posts/index'), 'base' => null, 'here' => '/posts/index');
$this->Controller->layout = 'default';
$View =& new DebugView($this->Controller, false);
$View->render('index');
$result = DebugKitDebugger::getTimers();
$this->assertEqual(count($result), 4);
$this->assertTrue(isset($result['viewRender']));
$this->assertTrue(isset($result['render_default.ctp']));
$this->assertTrue(isset($result['render_index.ctp']));
$result = DebugKitDebugger::getMemoryPoints();
$this->assertTrue(isset($result['View render complete']));
}
示例6: testBeforeRedirect
/**
* test that vars are gathered and state is saved on beforeRedirect
*
* @return void
**/
function testBeforeRedirect()
{
$this->Controller->components = array('DebugKit.Toolbar' => array('panels' => array('MockDebug', 'session', 'history')));
$this->Controller->Component->init($this->Controller);
$this->Controller->Component->initialize($this->Controller);
$configName = 'debug_kit';
$this->Controller->Toolbar->cacheKey = 'toolbar_history';
Cache::delete('toolbar_history', $configName);
DebugKitDebugger::startTimer('controllerAction', 'testing beforeRedirect');
$this->Controller->Toolbar->panels['MockDebug']->expectOnce('beforeRender');
$this->Controller->Toolbar->beforeRedirect($this->Controller);
$result = Cache::read('toolbar_history', $configName);
$this->assertTrue(isset($result[0]['session']));
$this->assertTrue(isset($result[0]['mock_debug']));
$timers = DebugKitDebugger::getTimers();
$this->assertTrue(isset($timers['controllerAction']));
}
示例7: testStartup
/**
* test startup
*
* @return void
**/
function testStartup()
{
$this->Controller->components = array('DebugKit.Toolbar' => array('panels' => array('MockDebug')));
$this->Controller->Component->init($this->Controller);
$this->Controller->Component->initialize($this->Controller);
$this->Controller->Toolbar->panels['MockDebug']->expectOnce('startup');
$this->Controller->Toolbar->startup($this->Controller);
$this->assertEqual(count($this->Controller->Toolbar->panels), 1);
$this->assertTrue(isset($this->Controller->helpers['DebugKit.Toolbar']));
$this->assertEqual($this->Controller->helpers['DebugKit.Toolbar']['output'], 'DebugKit.HtmlToolbar');
$this->assertEqual($this->Controller->helpers['DebugKit.Toolbar']['cacheConfig'], 'debug_kit');
$this->assertTrue(isset($this->Controller->helpers['DebugKit.Toolbar']['cacheKey']));
$timers = DebugKitDebugger::getTimers();
$this->assertTrue(isset($timers['controllerAction']));
}
示例8: testRenderTimers
/**
* test rendering and ensure that timers are being set.
*
* @return void
*/
public function testRenderTimers()
{
$request = new CakeRequest('/posts/index');
$request->addParams(Router::parse($request->url));
$request->addPaths(array('webroot' => '/', 'base' => '/', 'here' => '/posts/index'));
$this->Controller->setRequest($request);
$this->Controller->viewPath = 'posts';
$this->Controller->layout = 'default';
$View = new DebugView($this->Controller, false);
$View->render('index');
$result = DebugKitDebugger::getTimers();
$this->assertEqual(count($result), 4);
$this->assertTrue(isset($result['viewRender']));
$this->assertTrue(isset($result['render_default.ctp']));
$this->assertTrue(isset($result['render_index.ctp']));
$result = DebugKitDebugger::getMemoryPoints();
$this->assertTrue(isset($result['View render complete']));
}