Skip to content

Commit

Permalink
Update time calculation to use $_SERVER['REQUEST_TIME_FLOAT'] (PHP 5.4+)
Browse files Browse the repository at this point in the history
  • Loading branch information
jokkedk committed Mar 21, 2019
1 parent 5b15fce commit bf31482
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions library/ZFDebug/Controller/Plugin/Debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class ZFDebug_Controller_Plugin_Debug extends Zend_Controller_Plugin_Abstract
*
* @var string
*/
protected $_version = '1.6.4';
protected $_version = '1.6.5';

/**
* Creates a new instance of the Debug Bar
Expand Down Expand Up @@ -264,7 +264,7 @@ public function dispatchLoopShutdown()
$html .= '<span id="ZFDebugInfo_Request" class="ZFDebug_span">'
. "\n"
. round(memory_get_peak_usage()/1024) . 'K in '
. round((microtime(true)-$_SERVER['REQUEST_TIME'])*1000) . 'ms'
. round((microtime(true)-$_SERVER['REQUEST_TIME_FLOAT'])*1000) . 'ms'
. '</span>' . "\n";

$html .= "</div>\n";
Expand Down
4 changes: 2 additions & 2 deletions library/ZFDebug/Controller/Plugin/Debug/Plugin/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function getIconData()
*/
public function mark($name, $logFirst = false) {
if (isset($this->_marks[$name])) {
$this->_marks[$name]['time'] = round((microtime(true)-$_SERVER['REQUEST_TIME'])*1000-$this->_marks[$name]['time']).'ms';
$this->_marks[$name]['time'] = round((microtime(true)-$_SERVER['REQUEST_TIME_FLOAT'])*1000-$this->_marks[$name]['time']).'ms';
if (function_exists('memory_get_usage')) {
$this->_marks[$name]['memory'] = round((memory_get_usage()-$this->_marks[$name]['memory'])/1024) . 'K';
} else {
Expand All @@ -130,7 +130,7 @@ public function mark($name, $logFirst = false) {
)
);
} else {
$this->_marks[$name]['time'] = (microtime(true)-$_SERVER['REQUEST_TIME'])*1000;
$this->_marks[$name]['time'] = (microtime(true)-$_SERVER['REQUEST_TIME_FLOAT'])*1000;
if (function_exists('memory_get_usage')) {
$this->_marks[$name]['memory'] = memory_get_usage();
} else {
Expand Down

0 comments on commit bf31482

Please sign in to comment.