From 08012a6e41afd497d55f34fd5b621361f8b9c47d Mon Sep 17 00:00:00 2001 From: mohrt Date: Wed, 10 Oct 2001 23:58:36 +0000 Subject: [PATCH] fixed up execution time output in debug console --- NEWS | 2 +- Smarty.addons.php | 17 ++++++++++------- Smarty.class.php | 18 ++++++++++++------ Smarty_Compiler.class.php | 2 +- libs/Smarty.class.php | 18 ++++++++++++------ libs/Smarty_Compiler.class.php | 2 +- 6 files changed, 37 insertions(+), 22 deletions(-) diff --git a/NEWS b/NEWS index a0eefd40..3b217c83 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ - added support for hidden config variables that cannot be read by templates. (Andrei) - - added execution time to DEBUG console. (Monte) + - added execution time to DEBUG console, total and inserts. (Monte) - fixed bug where DEBUG console would not appear with cached content. (Monte) - added support for postfilter functions that are applied to compiled template right after compilation. (Andrei) diff --git a/Smarty.addons.php b/Smarty.addons.php index 8dd52ab0..ec0181c8 100644 --- a/Smarty.addons.php +++ b/Smarty.addons.php @@ -27,7 +27,7 @@ * * Or, write to: * Monte Ohrt - * CTO, ispi + * Directory of Technology, ispi * 237 S. 70th suite 220 * Lincoln, NE 68510 * @@ -682,16 +682,19 @@ function smarty_func_counter() { function smarty_func_assign_debug_info($args, &$smarty_obj) { $assigned_vars = $smarty_obj->_tpl_vars; ksort($assigned_vars); - $config_vars = $smarty_obj->_config[0]; - ksort($config_vars); + if(is_array($smarty_obj->_config[0])) { + $config_vars = $smarty_obj->_config[0]; + ksort($config_vars); + $smarty_obj->assign("_debug_config_keys",array_keys($config_vars)); + $smarty_obj->assign("_debug_config_vals",array_values($config_vars)); + } + $included_templates = $smarty_obj->_included_tpls; $smarty_obj->assign("_debug_keys",array_keys($assigned_vars)); $smarty_obj->assign("_debug_vals",array_values($assigned_vars)); - $smarty_obj->assign("_debug_config_keys",array_keys($config_vars)); - $smarty_obj->assign("_debug_config_vals",array_values($config_vars)); - $smarty_obj->assign("_debug_times_keys",array_keys($smarty_obj->_smarty_debug_times)); - $smarty_obj->assign("_debug_times_vals",array_values($smarty_obj->_smarty_debug_times)); + $smarty_obj->assign("_debug_times_keys",$smarty_obj->_smarty_debug_times['var']); + $smarty_obj->assign("_debug_times_vals",$smarty_obj->_smarty_debug_times['val']); $smarty_obj->assign("_debug_tpls",$included_templates); return true; diff --git a/Smarty.class.php b/Smarty.class.php index 423e73fe..6c5ff0f8 100644 --- a/Smarty.class.php +++ b/Smarty.class.php @@ -530,7 +530,8 @@ class Smarty if ($this->debugging) { // capture time for debugging info - $this->_smarty_debug_times["total"] = $this->_get_microtime() - $debug_start_time; + $this->_smarty_debug_times['var'][] = 'TOTAL'; + $this->_smarty_debug_times['val'][] = $this->_get_microtime() - $debug_start_time; echo $this->_generate_debug_output(); } @@ -604,7 +605,8 @@ class Smarty if ($this->debugging) { // capture time for debugging info - $this->_smarty_debug_times["TOTAL"] = $this->_get_microtime() - $debug_start_time; + $this->_smarty_debug_times['var'][] = 'TOTAL'; + $this->_smarty_debug_times['val'][] = $this->_get_microtime() - $debug_start_time; echo $this->_generate_debug_output(); } @@ -943,10 +945,12 @@ function _generate_debug_output() { $replace = $function_name($args, $this); $results = str_replace($cached_inserts[$i], $replace, $results); + if ($this->debugging) { + $this->_smarty_debug_times['var'][] = 'insert_'.$name; + $this->_smarty_debug_times['val'][] = $this->_get_microtime() - $debug_start_time; + } } - if ($this->debugging) - { $this->_smarty_debug_times["insert_".$name] = $this->_get_microtime() - $debug_start_time; } return $results; } @@ -967,8 +971,10 @@ function _run_insert_handler($args) } else { $function_name = 'insert_'.$args['name']; $content = $function_name($args, $this); - if ($this->debugging) - { $this->_smarty_debug_times["insert_".$args['name']] = $this->_get_microtime() - $debug_start_time; } + if ($this->debugging) { + $this->_smarty_debug_times['var'][] = 'insert_'.$args['name']; + $this->_smarty_debug_times['val'][] = $this->_get_microtime() - $debug_start_time; + } return $content; } } diff --git a/Smarty_Compiler.class.php b/Smarty_Compiler.class.php index b8d3ee4c..381d6eac 100644 --- a/Smarty_Compiler.class.php +++ b/Smarty_Compiler.class.php @@ -29,7 +29,7 @@ * * Or, write to: * Monte Ohrt - * CTO, ispi + * Director of Technology, ispi * 237 S. 70th suite 220 * Lincoln, NE 68510 * diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 423e73fe..6c5ff0f8 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -530,7 +530,8 @@ class Smarty if ($this->debugging) { // capture time for debugging info - $this->_smarty_debug_times["total"] = $this->_get_microtime() - $debug_start_time; + $this->_smarty_debug_times['var'][] = 'TOTAL'; + $this->_smarty_debug_times['val'][] = $this->_get_microtime() - $debug_start_time; echo $this->_generate_debug_output(); } @@ -604,7 +605,8 @@ class Smarty if ($this->debugging) { // capture time for debugging info - $this->_smarty_debug_times["TOTAL"] = $this->_get_microtime() - $debug_start_time; + $this->_smarty_debug_times['var'][] = 'TOTAL'; + $this->_smarty_debug_times['val'][] = $this->_get_microtime() - $debug_start_time; echo $this->_generate_debug_output(); } @@ -943,10 +945,12 @@ function _generate_debug_output() { $replace = $function_name($args, $this); $results = str_replace($cached_inserts[$i], $replace, $results); + if ($this->debugging) { + $this->_smarty_debug_times['var'][] = 'insert_'.$name; + $this->_smarty_debug_times['val'][] = $this->_get_microtime() - $debug_start_time; + } } - if ($this->debugging) - { $this->_smarty_debug_times["insert_".$name] = $this->_get_microtime() - $debug_start_time; } return $results; } @@ -967,8 +971,10 @@ function _run_insert_handler($args) } else { $function_name = 'insert_'.$args['name']; $content = $function_name($args, $this); - if ($this->debugging) - { $this->_smarty_debug_times["insert_".$args['name']] = $this->_get_microtime() - $debug_start_time; } + if ($this->debugging) { + $this->_smarty_debug_times['var'][] = 'insert_'.$args['name']; + $this->_smarty_debug_times['val'][] = $this->_get_microtime() - $debug_start_time; + } return $content; } } diff --git a/libs/Smarty_Compiler.class.php b/libs/Smarty_Compiler.class.php index b8d3ee4c..381d6eac 100644 --- a/libs/Smarty_Compiler.class.php +++ b/libs/Smarty_Compiler.class.php @@ -29,7 +29,7 @@ * * Or, write to: * Monte Ohrt - * CTO, ispi + * Director of Technology, ispi * 237 S. 70th suite 220 * Lincoln, NE 68510 *