本文整理匯總了PHP中DebugKitDebugger::elapsedTime方法的典型用法代碼示例。如果您正苦於以下問題:PHP DebugKitDebugger::elapsedTime方法的具體用法?PHP DebugKitDebugger::elapsedTime怎麽用?PHP DebugKitDebugger::elapsedTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DebugKitDebugger
的用法示例。
在下文中一共展示了DebugKitDebugger::elapsedTime方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testTimers
/**
* Start Timer test
*
* @return void
**/
function testTimers()
{
$this->assertTrue(DebugKitDebugger::startTimer('test1', 'this is my first test'));
usleep(5000);
$this->assertTrue(DebugKitDebugger::stopTimer('test1'));
$elapsed = DebugKitDebugger::elapsedTime('test1');
$this->assertTrue($elapsed > 0.005);
$this->assertTrue(DebugKitDebugger::startTimer('test2', 'this is my second test'));
sleep(1);
$this->assertTrue(DebugKitDebugger::stopTimer('test2'));
$elapsed = DebugKitDebugger::elapsedTime('test2');
$this->assertTrue($elapsed > 1);
DebugKitDebugger::startTimer('test3');
$this->assertFalse(DebugKitDebugger::elapsedTime('test3'));
$this->assertFalse(DebugKitDebugger::stopTimer('wrong'));
}
示例2: testTimers
/**
* Start Timer test
*
* @return void
**/
public function testTimers() {
$this->assertTrue(DebugKitDebugger::startTimer('test1', 'this is my first test'));
usleep(5000);
$this->assertTrue(DebugKitDebugger::stopTimer('test1'));
$elapsed = DebugKitDebugger::elapsedTime('test1');
$this->assertTrue($elapsed > 0.0050);
$this->assertTrue(DebugKitDebugger::startTimer('test2', 'this is my second test'));
sleep(1);
$this->assertTrue(DebugKitDebugger::stopTimer('test2'));
$elapsed = DebugKitDebugger::elapsedTime('test2');
$expected = strpos(PHP_OS, 'WIN') === false ? 1 : 0.95; // Windows timer's precision is bad
$this->assertTrue($elapsed > $expected);
DebugKitDebugger::startTimer('test3');
$this->assertIdentical(DebugKitDebugger::elapsedTime('test3'), 0);
$this->assertFalse(DebugKitDebugger::stopTimer('wrong'));
}
示例3: getTimers
/**
* Get all timers that have been started and stopped.
* Calculates elapsed time for each timer.
*
* @return array
**/
function getTimers()
{
$_this =& DebugKitDebugger::getInstance();
$times = array();
foreach ($_this->__benchmarks as $name => $timer) {
$times[$name]['time'] = DebugKitDebugger::elapsedTime($name);
$times[$name]['message'] = $timer['message'];
}
return $times;
}
示例4: getTimers
/**
* Get all timers that have been started and stopped.
* Calculates elapsed time for each timer. If clear is true, will delete existing timers
*
* @param bool $clear false
* @return array
* @access public
**/
function getTimers($clear = false)
{
$_this =& DebugKitDebugger::getInstance();
$start = DebugKitDebugger::requestStartTime();
$now = getMicrotime();
$times = array();
if (!empty($_this->__benchmarks)) {
$firstTimer = current($_this->__benchmarks);
$_end = $firstTimer['start'];
} else {
$_end = $now;
}
$times['Core Processing (Derived)'] = array('message' => __d('debug_kit', 'Core Processing (Derived)', true), 'start' => 0, 'end' => $_end - $start, 'time' => round($_end - $start, 6), 'named' => null);
foreach ($_this->__benchmarks as $name => $timer) {
if (!isset($timer['end'])) {
$timer['end'] = $now;
}
$times[$name] = array_merge($timer, array('start' => $timer['start'] - $start, 'end' => $timer['end'] - $start, 'time' => DebugKitDebugger::elapsedTime($name)));
}
if ($clear) {
$_this->__benchmarks = array();
}
return $times;
}