* [MOD] Improve elapsed time calc and code refactoring.

This commit is contained in:
nuxsmin
2017-04-20 13:31:49 +02:00
parent 1eadaf9882
commit fa65e08029
4 changed files with 6 additions and 12 deletions

View File

@@ -61,9 +61,8 @@ $ClassLoader->register();
require __DIR__ . DIRECTORY_SEPARATOR . 'BaseFunctions.php';
// Empezar a calcular el tiempo y memoria utilizados
// Empezar a calcular la memoria utilizada
$memInit = memory_get_usage();
$timeStart = microtime_float();
// Inicializar sysPass
Init::start();

View File

@@ -97,8 +97,7 @@ function mb_ucfirst($string)
*
* @returns float con el tiempo actual
*/
function microtime_float()
function getElapsedTime()
{
list($usec, $sec) = explode(' ', microtime());
return ((float)$usec + (float)$sec);
return microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'];
}

View File

@@ -131,12 +131,10 @@ abstract class ControllerBase
private function setViewVars()
{
global $timeStart;
$this->UserData = Session::getUserData();
$this->UserProfileData = Session::getUserProfile();
$this->view->assign('timeStart', $timeStart);
$this->view->assign('timeStart', $_SERVER['REQUEST_TIME_FLOAT']);
$this->view->assign('icons', $this->icons);
$this->view->assign('SessionUserData', $this->UserData);
}
@@ -192,7 +190,7 @@ abstract class ControllerBase
$this->view->addTemplate('debug', 'common');
$this->view->assign('time', microtime_float() - $this->view->timeStart);
$this->view->assign('time', getElapsedTime());
$this->view->assign('memInit', $memInit / 1000);
$this->view->assign('memEnd', memory_get_usage() / 1000);
}

View File

@@ -52,8 +52,6 @@ class Crypt
*/
public static function migrate(&$masterPass)
{
global $timeStart;
try {
AccountHistoryCrypt::$currentMPassHash = ConfigDB::getValue('masterPwd');
@@ -73,7 +71,7 @@ class Crypt
throw new SPException(SPException::SP_ERROR, __('No es posible finalizar una transacción', false));
}
debugLog('Total time: ' . (microtime_float() - $timeStart));
debugLog('Total time: ' . getElapsedTime());
return true;
} catch (\Exception $e) {