diff --git a/change_log.txt b/change_log.txt index c0aa5272..2c2d6669 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,3 +1,6 @@ +20/06/2010 +- replace internal get_time() calls with standard PHP5 microtime(true) calls + 18/06/2010 - added __toString method to the Smarty_Variable class diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 9b806ee1..90bfb899 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -243,7 +243,7 @@ class Smarty extends Smarty_Internal_Data { if (is_callable('mb_internal_encoding')) { mb_internal_encoding(SMARTY_RESOURCE_CHAR_SET); } - $this->start_time = $this->_get_time(); + $this->start_time = microtime(true); // set exception handler if (!empty($this->exception_handler)) set_exception_handler($this->exception_handler); diff --git a/libs/sysplugins/smarty_internal_data.php b/libs/sysplugins/smarty_internal_data.php index 3f45ccb9..7cfee408 100644 --- a/libs/sysplugins/smarty_internal_data.php +++ b/libs/sysplugins/smarty_internal_data.php @@ -374,17 +374,6 @@ class Smarty_Internal_Data { } } - /** - * return current time - * - * @returns double current time - */ - function _get_time() - { - $_mtime = microtime(); - $_mtime = explode(" ", $_mtime); - return (double)($_mtime[1]) + (double)($_mtime[0]); - } } /** diff --git a/libs/sysplugins/smarty_internal_debug.php b/libs/sysplugins/smarty_internal_debug.php index 9df0942d..5e2a3e9a 100644 --- a/libs/sysplugins/smarty_internal_debug.php +++ b/libs/sysplugins/smarty_internal_debug.php @@ -22,7 +22,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data { public static function start_compile($template) { $key = self::get_key($template); - self::$template_data[$key]['start_time'] = self::get_time(); + self::$template_data[$key]['start_time'] = microtime(true); } /** @@ -31,7 +31,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data { public static function end_compile($template) { $key = self::get_key($template); - self::$template_data[$key]['compile_time'] += self::get_time() - self::$template_data[$key]['start_time']; + self::$template_data[$key]['compile_time'] += microtime(true) - self::$template_data[$key]['start_time']; } /** @@ -40,7 +40,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data { public static function start_render($template) { $key = self::get_key($template); - self::$template_data[$key]['start_time'] = self::get_time(); + self::$template_data[$key]['start_time'] = microtime(true); } /** @@ -49,7 +49,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data { public static function end_render($template) { $key = self::get_key($template); - self::$template_data[$key]['render_time'] += self::get_time() - self::$template_data[$key]['start_time']; + self::$template_data[$key]['render_time'] += microtime(true) - self::$template_data[$key]['start_time']; } /** @@ -58,7 +58,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data { public static function start_cache($template) { $key = self::get_key($template); - self::$template_data[$key]['start_time'] = self::get_time(); + self::$template_data[$key]['start_time'] = microtime(true); } /** @@ -67,7 +67,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data { public static function end_cache($template) { $key = self::get_key($template); - self::$template_data[$key]['cache_time'] += self::get_time() - self::$template_data[$key]['start_time']; + self::$template_data[$key]['cache_time'] += microtime(true) - self::$template_data[$key]['start_time']; } /** * Opens a window for the Smarty Debugging Consol and display the data @@ -88,7 +88,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data { $_template->assign('template_data', self::$template_data); $_template->assign('assigned_vars', $_assigned_vars); $_template->assign('config_vars', $_config_vars); - $_template->assign('execution_time', $smarty->_get_time() - $smarty->start_time); + $_template->assign('execution_time', microtime(true) - $smarty->start_time); echo $smarty->fetch($_template); } @@ -113,17 +113,6 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data { } } - /** - * return current time - * - * @returns double current time - */ - static function get_time() - { - $_mtime = microtime(); - $_mtime = explode(" ", $_mtime); - return (double)($_mtime[1]) + (double)($_mtime[0]); - } } -?> +?> \ No newline at end of file diff --git a/libs/sysplugins/smarty_internal_utility.php b/libs/sysplugins/smarty_internal_utility.php index 9949e7a3..61528c50 100644 --- a/libs/sysplugins/smarty_internal_utility.php +++ b/libs/sysplugins/smarty_internal_utility.php @@ -273,15 +273,4 @@ class Smarty_Internal_Utility { return true; } - /** - * Get Micro Time - * - * @return double micro time - */ - function _get_time() - { - $_mtime = microtime(); - $_mtime = explode(" ", $_mtime); - return (double)($_mtime[1]) + (double)($_mtime[0]); - } }