mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-04 15:44:07 +01:00
* [MOD] Improve elapsed time calc and code refactoring.
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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'];
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user