Public Member Functions | |
| CI_Profiler () | |
| _compile_benchmarks () | |
| Auto Profiler. | |
| _compile_queries () | |
| Compile Queries. | |
| _compile_get () | |
| Compile $_GET Data. | |
| _compile_post () | |
| Compile $_POST Data. | |
| _compile_uri_string () | |
| Show query string. | |
| _compile_memory_usage () | |
| Compile memory usage. | |
| run () | |
| Run the Profiler. | |
Public Attributes | |
| $CI | |
Definition at line 33 of file Profiler.php.
| CI_Profiler::_compile_benchmarks | ( | ) |
Auto Profiler.
This function cycles through the entire array of mark points and matches any two points that are named identically (ending in "_start" and "_end" respectively). It then compiles the execution times for all points and returns it as an array
private
Definition at line 56 of file Profiler.php.
Referenced by run().
00057 { 00058 $profile = array(); 00059 foreach ($this->CI->benchmark->marker as $key => $val) 00060 { 00061 // We match the "end" marker so that the list ends 00062 // up in the order that it was defined 00063 if (preg_match("/(.+?)_end/i", $key, $match)) 00064 { 00065 if (isset($this->CI->benchmark->marker[$match[1].'_end']) AND isset($this->CI->benchmark->marker[$match[1].'_start'])) 00066 { 00067 $profile[$match[1]] = $this->CI->benchmark->elapsed_time($match[1].'_start', $key); 00068 } 00069 } 00070 } 00071 00072 // Build a table containing the profile data. 00073 // Note: At some point we should turn this into a template that can 00074 // be modified. We also might want to make this data available to be logged 00075 00076 $output = "\n\n"; 00077 $output .= '<fieldset style="border:1px solid #990000;padding:6px 10px 10px 10px;margin:0 0 20px 0;background-color:#eee">'; 00078 $output .= "\n"; 00079 $output .= '<legend style="color:#990000;"> '.$this->CI->lang->line('profiler_benchmarks').' </legend>'; 00080 $output .= "\n"; 00081 $output .= "\n\n<table cellpadding='4' cellspacing='1' border='0' width='100%'>\n"; 00082 00083 foreach ($profile as $key => $val) 00084 { 00085 $key = ucwords(str_replace(array('_', '-'), ' ', $key)); 00086 $output .= "<tr><td width='50%' style='color:#000;font-weight:bold;background-color:#ddd;'>".$key." </td><td width='50%' style='color:#990000;font-weight:normal;background-color:#ddd;'>".$val."</td></tr>\n"; 00087 } 00088 00089 $output .= "</table>\n"; 00090 $output .= "</fieldset>"; 00091 00092 return $output; 00093 }

| CI_Profiler::_compile_get | ( | ) |
Compile $_GET Data.
private
Definition at line 160 of file Profiler.php.
Referenced by run().
00161 { 00162 $output = "\n\n"; 00163 $output .= '<fieldset style="border:1px solid #cd6e00;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; 00164 $output .= "\n"; 00165 $output .= '<legend style="color:#cd6e00;"> '.$this->CI->lang->line('profiler_get_data').' </legend>'; 00166 $output .= "\n"; 00167 00168 if (count($_GET) == 0) 00169 { 00170 $output .= "<div style='color:#cd6e00;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_get')."</div>"; 00171 } 00172 else 00173 { 00174 $output .= "\n\n<table cellpadding='4' cellspacing='1' border='0' width='100%'>\n"; 00175 00176 foreach ($_GET as $key => $val) 00177 { 00178 if ( ! is_numeric($key)) 00179 { 00180 $key = "'".$key."'"; 00181 } 00182 00183 $output .= "<tr><td width='50%' style='color:#000;background-color:#ddd;'>$_GET[".$key."] </td><td width='50%' style='color:#cd6e00;font-weight:normal;background-color:#ddd;'>"; 00184 if (is_array($val)) 00185 { 00186 $output .= "<pre>" . htmlspecialchars(stripslashes(print_r($val, true))) . "</pre>"; 00187 } 00188 else 00189 { 00190 $output .= htmlspecialchars(stripslashes($val)); 00191 } 00192 $output .= "</td></tr>\n"; 00193 } 00194 00195 $output .= "</table>\n"; 00196 } 00197 $output .= "</fieldset>"; 00198 00199 return $output; 00200 }

| CI_Profiler::_compile_memory_usage | ( | ) |
Compile memory usage.
Display total used memory
public
Definition at line 293 of file Profiler.php.
Referenced by run().
00294 { 00295 $output = "\n\n"; 00296 $output .= '<fieldset style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; 00297 $output .= "\n"; 00298 $output .= '<legend style="color:#000;"> '.$this->CI->lang->line('profiler_memory_usage').' </legend>'; 00299 $output .= "\n"; 00300 00301 if (function_exists('memory_get_usage') && ($usage = memory_get_usage()) != '') 00302 { 00303 $output .= "<div style='color:#000;font-weight:normal;padding:4px 0 4px 0'>".number_format($usage).' bytes</div>'; 00304 } 00305 else 00306 { 00307 $output .= "<div style='color:#000;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_memory_usage')."</div>"; 00308 } 00309 00310 $output .= "</fieldset>"; 00311 00312 return $output; 00313 }

| CI_Profiler::_compile_post | ( | ) |
Compile $_POST Data.
private
Definition at line 210 of file Profiler.php.
Referenced by run().
00211 { 00212 $output = "\n\n"; 00213 $output .= '<fieldset style="border:1px solid #009900;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; 00214 $output .= "\n"; 00215 $output .= '<legend style="color:#009900;"> '.$this->CI->lang->line('profiler_post_data').' </legend>'; 00216 $output .= "\n"; 00217 00218 if (count($_POST) == 0) 00219 { 00220 $output .= "<div style='color:#009900;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_post')."</div>"; 00221 } 00222 else 00223 { 00224 $output .= "\n\n<table cellpadding='4' cellspacing='1' border='0' width='100%'>\n"; 00225 00226 foreach ($_POST as $key => $val) 00227 { 00228 if ( ! is_numeric($key)) 00229 { 00230 $key = "'".$key."'"; 00231 } 00232 00233 // $output .= "<tr><td width='50%' style='color:#000;background-color:#ddd;'>$_POST[".$key."] </td><td width='50%' style='color:#009900;font-weight:normal;background-color:#ddd;'>".htmlspecialchars(stripslashes($val))."</td></tr>\n"; 00234 $output .= "<tr><td width='50%' style='color:#000;background-color:#ddd;'>$_POST[".$key."] </td><td width='50%' style='color:#009900;font-weight:normal;background-color:#ddd;'>"; 00235 if (is_array($val)) 00236 { 00237 $output .= "<pre>" . htmlspecialchars(stripslashes(print_r($val, true))) . "</pre>"; 00238 } 00239 else 00240 { 00241 $output .= htmlspecialchars(stripslashes($val)); 00242 } 00243 $output .= "</td></tr>\n"; 00244 } 00245 00246 $output .= "</table>\n"; 00247 } 00248 $output .= "</fieldset>"; 00249 00250 return $output; 00251 }

| CI_Profiler::_compile_queries | ( | ) |
Compile Queries.
private
Definition at line 103 of file Profiler.php.
Referenced by run().
00104 { 00105 $output = "\n\n"; 00106 $output .= '<fieldset style="border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; 00107 $output .= "\n"; 00108 00109 if ( ! class_exists('CI_DB_driver')) 00110 { 00111 $output .= '<legend style="color:#0000FF;"> '.$this->CI->lang->line('profiler_queries').' </legend>'; 00112 $output .= "\n"; 00113 $output .= "\n\n<table cellpadding='4' cellspacing='1' border='0' width='100%'>\n"; 00114 $output .="<tr><td width='100%' style='color:#0000FF;font-weight:normal;background-color:#eee;'>".$this->CI->lang->line('profiler_no_db')."</td></tr>\n"; 00115 } 00116 else 00117 { 00118 $output .= '<legend style="color:#0000FF;"> '.$this->CI->lang->line('profiler_queries').' ('.count($this->CI->db->queries).') </legend>'; 00119 $output .= "\n"; 00120 $output .= "\n\n<table cellpadding='4' cellspacing='1' border='0' width='100%'>\n"; 00121 00122 if (count($this->CI->db->queries) == 0) 00123 { 00124 $output .= "<tr><td width='100%' style='color:#0000FF;font-weight:normal;background-color:#eee;'>".$this->CI->lang->line('profiler_no_queries')."</td></tr>\n"; 00125 } 00126 else 00127 { 00128 $highlight = array('SELECT', 'FROM', 'WHERE', 'AND', 'LEFT JOIN', 'ORDER BY', 'LIMIT', 'INSERT', 'INTO', 'VALUES', 'UPDATE', 'OR'); 00129 00130 foreach ($this->CI->db->queries as $key => $val) 00131 { 00132 $val = htmlspecialchars($val, ENT_QUOTES); 00133 $time = number_format($this->CI->db->query_times[$key], 4); 00134 00135 foreach ($highlight as $bold) 00136 { 00137 $val = str_replace($bold, '<strong>'.$bold.'</strong>', $val); 00138 } 00139 00140 $output .= "<tr><td width='1%' valign='top' style='color:#990000;font-weight:normal;background-color:#ddd;'>".$time." </td><td style='color:#000;font-weight:normal;background-color:#ddd;'>".$val."</td></tr>\n"; 00141 } 00142 } 00143 } 00144 00145 $output .= "</table>\n"; 00146 $output .= "</fieldset>"; 00147 00148 return $output; 00149 }

| CI_Profiler::_compile_uri_string | ( | ) |
Show query string.
private
Definition at line 261 of file Profiler.php.
Referenced by run().
00262 { 00263 $output = "\n\n"; 00264 $output .= '<fieldset style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; 00265 $output .= "\n"; 00266 $output .= '<legend style="color:#000;"> '.$this->CI->lang->line('profiler_uri_string').' </legend>'; 00267 $output .= "\n"; 00268 00269 if ($this->CI->uri->uri_string == '') 00270 { 00271 $output .= "<div style='color:#000;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_uri')."</div>"; 00272 } 00273 else 00274 { 00275 $output .= "<div style='color:#000;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->uri->uri_string."</div>"; 00276 } 00277 00278 $output .= "</fieldset>"; 00279 00280 return $output; 00281 }

| CI_Profiler::CI_Profiler | ( | ) |
Definition at line 37 of file Profiler.php.
References get_instance().
00038 { 00039 $this->CI =& get_instance(); 00040 $this->CI->load->language('profiler'); 00041 }

| CI_Profiler::run | ( | ) |
Run the Profiler.
private
Definition at line 323 of file Profiler.php.
References _compile_benchmarks(), _compile_get(), _compile_memory_usage(), _compile_post(), _compile_queries(), and _compile_uri_string().
00324 { 00325 $output = '<br clear="all" />'; 00326 $output .= "<div style='background-color:#fff;padding:10px;'>"; 00327 00328 $output .= $this->_compile_memory_usage(); 00329 $output .= $this->_compile_benchmarks(); 00330 $output .= $this->_compile_uri_string(); 00331 $output .= $this->_compile_get(); 00332 $output .= $this->_compile_post(); 00333 $output .= $this->_compile_queries(); 00334 00335 $output .= '</div>'; 00336 00337 return $output; 00338 }

| CI_Profiler::$CI |
Definition at line 35 of file Profiler.php.