mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Convert getMictime() php4 hack to microtime(true)
This commit is contained in:
parent
0384ecad30
commit
c7fcaf995f
7 changed files with 8 additions and 31 deletions
|
@ -106,18 +106,6 @@
|
|||
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')) {
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,7 +28,7 @@ if (!defined('E_DEPRECATED')) {
|
|||
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';
|
||||
|
|
|
@ -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 -->";
|
||||
}
|
||||
?>
|
|
@ -531,7 +531,7 @@ class Dispatcher extends Object {
|
|||
}
|
||||
$controller = null;
|
||||
$view =& new View($controller);
|
||||
$return = $view->renderCache($filename, getMicrotime());
|
||||
$return = $view->renderCache($filename, microtime(true));
|
||||
if (!$return) {
|
||||
ClassRegistry::removeObject('view');
|
||||
}
|
||||
|
|
|
@ -232,10 +232,10 @@ class DboSource extends DataSource {
|
|||
$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();
|
||||
|
|
|
@ -525,7 +525,7 @@ class View extends Object {
|
|||
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();
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ class CakeBaseReporter extends SimpleReporter {
|
|||
*/
|
||||
public function paintGroupStart($test_name, $size) {
|
||||
if (empty($this->_timeStart)) {
|
||||
$this->_timeStart = $this->_getTime();
|
||||
$this->_timeStart = microtime(true);
|
||||
}
|
||||
parent::paintGroupStart($test_name, $size);
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ class CakeBaseReporter extends SimpleReporter {
|
|||
* @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);
|
||||
}
|
||||
|
@ -145,17 +145,6 @@ class CakeBaseReporter extends SimpleReporter {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
|
Loading…
Reference in a new issue