function timer_stop
Stops the timer with the specified name.
Parameters
$name: The name of the timer.
Return value
A timer array. The array contains the number of times the timer has been started and stopped (count) and the accumulated timer value in ms (time).
2 calls to timer_stop()
- BootstrapTimerTestCase::testTimer in modules/
simpletest/ tests/ bootstrap.test - Test timer_read() to ensure it properly accumulates time when the timer started and stopped multiple times.
- drupal_cron_run in includes/
common.inc - Executes a cron run when called.
File
-
includes/
bootstrap.inc, line 522
Code
function timer_stop($name) {
global $timers;
if (isset($timers[$name]['start'])) {
$stop = microtime(TRUE);
$diff = round(($stop - $timers[$name]['start']) * 1000, 2);
if (isset($timers[$name]['time'])) {
$timers[$name]['time'] += $diff;
}
else {
$timers[$name]['time'] = $diff;
}
unset($timers[$name]['start']);
}
return $timers[$name];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.