Skip to content

Commit

Permalink
Convert getMictime() php4 hack to microtime(true)
Browse files Browse the repository at this point in the history
  • Loading branch information
predominant committed Apr 15, 2010
1 parent 0384eca commit c7fcaf9
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 31 deletions.
12 changes: 0 additions & 12 deletions cake/basics.php
Expand Up @@ -106,18 +106,6 @@ function debug($var = false, $showHtml = false, $showFrom = true) {
echo $var . "\n</pre>\n";
}
}
if (!function_exists('getMicrotime')) {

/**
* Returns microtime for execution time checking
*
* @return float Microtime
*/
function getMicrotime() {
list($usec, $sec) = explode(' ', microtime());
return ((float)$usec + (float)$sec);
}
}
if (!function_exists('sortByKey')) {

/**
Expand Down
2 changes: 1 addition & 1 deletion cake/bootstrap.php
Expand Up @@ -28,7 +28,7 @@
error_reporting(E_ALL & ~E_DEPRECATED);

require CORE_PATH . 'cake' . DS . 'basics.php';
$TIME_START = getMicrotime();
$TIME_START = microtime(true);
require CORE_PATH . 'cake' . DS . 'config' . DS . 'paths.php';
require LIBS . 'object.php';
require LIBS . 'inflector.php';
Expand Down
2 changes: 1 addition & 1 deletion cake/console/templates/skel/webroot/index.php
Expand Up @@ -83,6 +83,6 @@
$Dispatcher->dispatch();
}
if (Configure::read() > 0) {
echo "<!-- " . round(getMicrotime() - $TIME_START, 4) . "s -->";
echo "<!-- " . round(microtime(true) - $TIME_START, 4) . "s -->";
}
?>
2 changes: 1 addition & 1 deletion cake/dispatcher.php
Expand Up @@ -531,7 +531,7 @@ public function cached($url) {
}
$controller = null;
$view =& new View($controller);
$return = $view->renderCache($filename, getMicrotime());
$return = $view->renderCache($filename, microtime(true));
if (!$return) {
ClassRegistry::removeObject('view');
}
Expand Down
4 changes: 2 additions & 2 deletions cake/libs/model/datasources/dbo_source.php
Expand Up @@ -232,10 +232,10 @@ public function execute($sql, $options = array()) {
$defaults = array('stats' => true, 'log' => $this->fullDebug);
$options = array_merge($defaults, $options);

$t = getMicrotime();
$t = microtime(true);
$this->_result = $this->_execute($sql);
if ($options['stats']) {
$this->took = round((getMicrotime() - $t) * 1000, 0);
$this->took = round((microtime(true) - $t) * 1000, 0);
$this->affected = $this->lastAffected();
$this->error = $this->lastError();
$this->numRows = $this->lastNumRows();
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/view/view.php
Expand Up @@ -525,7 +525,7 @@ public function renderCache($filename, $timeStart) {
include ($filename);

if (Configure::read() > 0 && $this->layout != 'xml') {
echo "<!-- Cached Render Time: " . round(getMicrotime() - $timeStart, 4) . "s -->";
echo "<!-- Cached Render Time: " . round(microtime(true) - $timeStart, 4) . "s -->";
}
$out = ob_get_clean();

Expand Down
15 changes: 2 additions & 13 deletions cake/tests/lib/reporter/cake_base_reporter.php
Expand Up @@ -99,7 +99,7 @@ function __construct($charset = 'utf-8', $params = array()) {
*/
public function paintGroupStart($test_name, $size) {
if (empty($this->_timeStart)) {
$this->_timeStart = $this->_getTime();
$this->_timeStart = microtime(true);
}
parent::paintGroupStart($test_name, $size);
}
Expand All @@ -112,7 +112,7 @@ public function paintGroupStart($test_name, $size) {
* @return void
*/
public function paintGroupEnd($test_name) {
$this->_timeEnd = $this->_getTime();
$this->_timeEnd = microtime(true);
$this->_timeDuration = $this->_timeEnd - $this->_timeStart;
parent::paintGroupEnd($test_name);
}
Expand Down Expand Up @@ -145,17 +145,6 @@ public function paintMethodEnd($method) {
}
}

/**
* Get the current time in microseconds. Similar to getMicrotime in basics.php
* but in a separate function to reduce dependancies.
*
* @return float Time in microseconds
*/
protected function _getTime() {
list($usec, $sec) = explode(' ', microtime());
return ((float)$sec + (float)$usec);
}

/**
* Retrieves a list of test cases from the active Manager class,
* displaying it in the correct format for the reporter subclass
Expand Down

0 comments on commit c7fcaf9

Please sign in to comment.