Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1 | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
| 2 | /** |
| 3 | * CodeIgniter |
| 4 | * |
| 5 | * An open source application development framework for PHP 4.3.2 or newer |
| 6 | * |
| 7 | * @package CodeIgniter |
| 8 | * @author ExpressionEngine Dev Team |
Derek Jones | 7f3719f | 2010-01-05 13:35:37 +0000 | [diff] [blame] | 9 | * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 10 | * @license http://codeigniter.com/user_guide/license.html |
| 11 | * @link http://codeigniter.com |
| 12 | * @since Version 1.0 |
| 13 | * @filesource |
| 14 | */ |
| 15 | |
| 16 | // ------------------------------------------------------------------------ |
| 17 | |
| 18 | /** |
| 19 | * CodeIgniter Profiler Class |
| 20 | * |
| 21 | * This class enables you to display benchmark, query, and other data |
| 22 | * in order to help with debugging and optimization. |
| 23 | * |
| 24 | * Note: At some point it would be good to move all the HTML in this class |
| 25 | * into a set of template files in order to allow customization. |
| 26 | * |
| 27 | * @package CodeIgniter |
| 28 | * @subpackage Libraries |
| 29 | * @category Libraries |
| 30 | * @author ExpressionEngine Dev Team |
| 31 | * @link http://codeigniter.com/user_guide/general/profiling.html |
| 32 | */ |
| 33 | class CI_Profiler { |
| 34 | |
| 35 | var $CI; |
| 36 | |
Derek Jones | ee71c80 | 2010-03-10 10:05:05 -0600 | [diff] [blame^] | 37 | var $_available_sections = array( |
| 38 | 'benchmarks', |
| 39 | 'config', |
| 40 | 'controller_info', |
| 41 | 'get', |
| 42 | 'http_headers', |
| 43 | 'memory_usage', |
| 44 | 'post', |
| 45 | 'queries', |
| 46 | 'uri_string' |
| 47 | ); |
| 48 | |
| 49 | function CI_Profiler($config = array()) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 50 | { |
| 51 | $this->CI =& get_instance(); |
| 52 | $this->CI->load->language('profiler'); |
Derek Jones | ee71c80 | 2010-03-10 10:05:05 -0600 | [diff] [blame^] | 53 | |
| 54 | // default all sections to display |
| 55 | foreach ($this->_available_sections as $section) |
| 56 | { |
| 57 | if ( ! isset($config[$section])) |
| 58 | { |
| 59 | $this->_compile_{$section} = TRUE; |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | $this->set_sections($config); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | // -------------------------------------------------------------------- |
| 67 | |
| 68 | /** |
Derek Jones | ee71c80 | 2010-03-10 10:05:05 -0600 | [diff] [blame^] | 69 | * Set Sections |
| 70 | * |
| 71 | * Sets the private _compile_* properties to enable/disable Profiler sections |
| 72 | * |
| 73 | * @access public |
| 74 | * @param mixed |
| 75 | * @return void |
| 76 | */ |
| 77 | function set_sections($config) |
| 78 | { |
| 79 | foreach ($config as $method => $enable) |
| 80 | { |
| 81 | if (in_array($method, $this->_available_sections)) |
| 82 | { |
| 83 | $this->_compile_{$method} = ($enable !== FALSE) ? TRUE : FALSE; |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | // -------------------------------------------------------------------- |
| 89 | |
| 90 | /** |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 91 | * Auto Profiler |
| 92 | * |
| 93 | * This function cycles through the entire array of mark points and |
| 94 | * matches any two points that are named identically (ending in "_start" |
| 95 | * and "_end" respectively). It then compiles the execution times for |
| 96 | * all points and returns it as an array |
Derek Jones | ee71c80 | 2010-03-10 10:05:05 -0600 | [diff] [blame^] | 97 | * @PHP4 - all methods should be declared private |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 98 | * @access private |
| 99 | * @return array |
| 100 | */ |
| 101 | function _compile_benchmarks() |
| 102 | { |
| 103 | $profile = array(); |
| 104 | foreach ($this->CI->benchmark->marker as $key => $val) |
| 105 | { |
| 106 | // We match the "end" marker so that the list ends |
| 107 | // up in the order that it was defined |
| 108 | if (preg_match("/(.+?)_end/i", $key, $match)) |
| 109 | { |
| 110 | if (isset($this->CI->benchmark->marker[$match[1].'_end']) AND isset($this->CI->benchmark->marker[$match[1].'_start'])) |
| 111 | { |
| 112 | $profile[$match[1]] = $this->CI->benchmark->elapsed_time($match[1].'_start', $key); |
| 113 | } |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | // Build a table containing the profile data. |
| 118 | // Note: At some point we should turn this into a template that can |
| 119 | // be modified. We also might want to make this data available to be logged |
| 120 | |
| 121 | $output = "\n\n"; |
Derek Allard | 76af409 | 2010-01-16 19:20:49 +0000 | [diff] [blame] | 122 | $output .= '<fieldset style="border:1px solid #900;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 123 | $output .= "\n"; |
Derek Allard | 76af409 | 2010-01-16 19:20:49 +0000 | [diff] [blame] | 124 | $output .= '<legend style="color:#900;"> '.$this->CI->lang->line('profiler_benchmarks').' </legend>'; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 125 | $output .= "\n"; |
| 126 | $output .= "\n\n<table cellpadding='4' cellspacing='1' border='0' width='100%'>\n"; |
| 127 | |
| 128 | foreach ($profile as $key => $val) |
| 129 | { |
| 130 | $key = ucwords(str_replace(array('_', '-'), ' ', $key)); |
Derek Allard | 76af409 | 2010-01-16 19:20:49 +0000 | [diff] [blame] | 131 | $output .= "<tr><td width='50%' style='color:#000;font-weight:bold;background-color:#ddd;'>".$key." </td><td width='50%' style='color:#900;font-weight:normal;background-color:#ddd;'>".$val."</td></tr>\n"; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | $output .= "</table>\n"; |
| 135 | $output .= "</fieldset>"; |
| 136 | |
| 137 | return $output; |
| 138 | } |
| 139 | |
| 140 | // -------------------------------------------------------------------- |
| 141 | |
| 142 | /** |
| 143 | * Compile Queries |
| 144 | * |
| 145 | * @access private |
| 146 | * @return string |
| 147 | */ |
| 148 | function _compile_queries() |
| 149 | { |
| 150 | $dbs = array(); |
Derek Jones | f0a9b33 | 2009-07-29 14:19:18 +0000 | [diff] [blame] | 151 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 152 | // Let's determine which databases are currently connected to |
| 153 | foreach (get_object_vars($this->CI) as $CI_object) |
| 154 | { |
Derek Jones | f0a9b33 | 2009-07-29 14:19:18 +0000 | [diff] [blame] | 155 | if (is_object($CI_object) && is_subclass_of(get_class($CI_object), 'CI_DB') ) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 156 | { |
| 157 | $dbs[] = $CI_object; |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | if (count($dbs) == 0) |
| 162 | { |
| 163 | $output = "\n\n"; |
| 164 | $output .= '<fieldset style="border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; |
| 165 | $output .= "\n"; |
| 166 | $output .= '<legend style="color:#0000FF;"> '.$this->CI->lang->line('profiler_queries').' </legend>'; |
| 167 | $output .= "\n"; |
| 168 | $output .= "\n\n<table cellpadding='4' cellspacing='1' border='0' width='100%'>\n"; |
| 169 | $output .="<tr><td width='100%' style='color:#0000FF;font-weight:normal;background-color:#eee;'>".$this->CI->lang->line('profiler_no_db')."</td></tr>\n"; |
| 170 | $output .= "</table>\n"; |
| 171 | $output .= "</fieldset>"; |
| 172 | |
| 173 | return $output; |
| 174 | } |
| 175 | |
| 176 | // Load the text helper so we can highlight the SQL |
| 177 | $this->CI->load->helper('text'); |
| 178 | |
| 179 | // Key words we want bolded |
| 180 | $highlight = array('SELECT', 'DISTINCT', 'FROM', 'WHERE', 'AND', 'LEFT JOIN', 'ORDER BY', 'GROUP BY', 'LIMIT', 'INSERT', 'INTO', 'VALUES', 'UPDATE', 'OR', 'HAVING', 'OFFSET', 'NOT IN', 'IN', 'LIKE', 'NOT LIKE', 'COUNT', 'MAX', 'MIN', 'ON', 'AS', 'AVG', 'SUM', '(', ')'); |
| 181 | |
| 182 | $output = "\n\n"; |
| 183 | |
| 184 | foreach ($dbs as $db) |
| 185 | { |
| 186 | $output .= '<fieldset style="border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; |
| 187 | $output .= "\n"; |
| 188 | $output .= '<legend style="color:#0000FF;"> '.$this->CI->lang->line('profiler_database').': '.$db->database.' '.$this->CI->lang->line('profiler_queries').': '.count($this->CI->db->queries).' </legend>'; |
| 189 | $output .= "\n"; |
| 190 | $output .= "\n\n<table cellpadding='4' cellspacing='1' border='0' width='100%'>\n"; |
| 191 | |
| 192 | if (count($db->queries) == 0) |
| 193 | { |
| 194 | $output .= "<tr><td width='100%' style='color:#0000FF;font-weight:normal;background-color:#eee;'>".$this->CI->lang->line('profiler_no_queries')."</td></tr>\n"; |
| 195 | } |
| 196 | else |
| 197 | { |
| 198 | foreach ($db->queries as $key => $val) |
| 199 | { |
| 200 | $time = number_format($db->query_times[$key], 4); |
| 201 | |
| 202 | $val = highlight_code($val, ENT_QUOTES); |
| 203 | |
| 204 | foreach ($highlight as $bold) |
| 205 | { |
| 206 | $val = str_replace($bold, '<strong>'.$bold.'</strong>', $val); |
| 207 | } |
| 208 | |
Derek Allard | 76af409 | 2010-01-16 19:20:49 +0000 | [diff] [blame] | 209 | $output .= "<tr><td width='1%' valign='top' style='color:#900;font-weight:normal;background-color:#ddd;'>".$time." </td><td style='color:#000;font-weight:normal;background-color:#ddd;'>".$val."</td></tr>\n"; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 210 | } |
| 211 | } |
| 212 | |
| 213 | $output .= "</table>\n"; |
| 214 | $output .= "</fieldset>"; |
| 215 | |
| 216 | } |
| 217 | |
| 218 | return $output; |
| 219 | } |
| 220 | |
| 221 | |
| 222 | // -------------------------------------------------------------------- |
| 223 | |
| 224 | /** |
| 225 | * Compile $_GET Data |
| 226 | * |
| 227 | * @access private |
| 228 | * @return string |
| 229 | */ |
| 230 | function _compile_get() |
| 231 | { |
| 232 | $output = "\n\n"; |
| 233 | $output .= '<fieldset style="border:1px solid #cd6e00;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; |
| 234 | $output .= "\n"; |
| 235 | $output .= '<legend style="color:#cd6e00;"> '.$this->CI->lang->line('profiler_get_data').' </legend>'; |
| 236 | $output .= "\n"; |
| 237 | |
| 238 | if (count($_GET) == 0) |
| 239 | { |
| 240 | $output .= "<div style='color:#cd6e00;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_get')."</div>"; |
| 241 | } |
| 242 | else |
| 243 | { |
| 244 | $output .= "\n\n<table cellpadding='4' cellspacing='1' border='0' width='100%'>\n"; |
| 245 | |
| 246 | foreach ($_GET as $key => $val) |
| 247 | { |
| 248 | if ( ! is_numeric($key)) |
| 249 | { |
| 250 | $key = "'".$key."'"; |
| 251 | } |
| 252 | |
| 253 | $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;'>"; |
| 254 | if (is_array($val)) |
| 255 | { |
| 256 | $output .= "<pre>" . htmlspecialchars(stripslashes(print_r($val, true))) . "</pre>"; |
| 257 | } |
| 258 | else |
| 259 | { |
| 260 | $output .= htmlspecialchars(stripslashes($val)); |
| 261 | } |
| 262 | $output .= "</td></tr>\n"; |
| 263 | } |
| 264 | |
| 265 | $output .= "</table>\n"; |
| 266 | } |
| 267 | $output .= "</fieldset>"; |
| 268 | |
| 269 | return $output; |
| 270 | } |
| 271 | |
| 272 | // -------------------------------------------------------------------- |
| 273 | |
| 274 | /** |
| 275 | * Compile $_POST Data |
| 276 | * |
| 277 | * @access private |
| 278 | * @return string |
| 279 | */ |
| 280 | function _compile_post() |
| 281 | { |
| 282 | $output = "\n\n"; |
| 283 | $output .= '<fieldset style="border:1px solid #009900;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; |
| 284 | $output .= "\n"; |
| 285 | $output .= '<legend style="color:#009900;"> '.$this->CI->lang->line('profiler_post_data').' </legend>'; |
| 286 | $output .= "\n"; |
| 287 | |
| 288 | if (count($_POST) == 0) |
| 289 | { |
| 290 | $output .= "<div style='color:#009900;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_post')."</div>"; |
| 291 | } |
| 292 | else |
| 293 | { |
| 294 | $output .= "\n\n<table cellpadding='4' cellspacing='1' border='0' width='100%'>\n"; |
| 295 | |
| 296 | foreach ($_POST as $key => $val) |
| 297 | { |
| 298 | if ( ! is_numeric($key)) |
| 299 | { |
| 300 | $key = "'".$key."'"; |
| 301 | } |
| 302 | |
| 303 | $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;'>"; |
| 304 | if (is_array($val)) |
| 305 | { |
| 306 | $output .= "<pre>" . htmlspecialchars(stripslashes(print_r($val, true))) . "</pre>"; |
| 307 | } |
| 308 | else |
| 309 | { |
| 310 | $output .= htmlspecialchars(stripslashes($val)); |
| 311 | } |
| 312 | $output .= "</td></tr>\n"; |
| 313 | } |
| 314 | |
| 315 | $output .= "</table>\n"; |
| 316 | } |
| 317 | $output .= "</fieldset>"; |
| 318 | |
| 319 | return $output; |
| 320 | } |
| 321 | |
| 322 | // -------------------------------------------------------------------- |
| 323 | |
| 324 | /** |
| 325 | * Show query string |
| 326 | * |
| 327 | * @access private |
| 328 | * @return string |
| 329 | */ |
| 330 | function _compile_uri_string() |
| 331 | { |
| 332 | $output = "\n\n"; |
| 333 | $output .= '<fieldset style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; |
| 334 | $output .= "\n"; |
| 335 | $output .= '<legend style="color:#000;"> '.$this->CI->lang->line('profiler_uri_string').' </legend>'; |
| 336 | $output .= "\n"; |
| 337 | |
| 338 | if ($this->CI->uri->uri_string == '') |
| 339 | { |
| 340 | $output .= "<div style='color:#000;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_uri')."</div>"; |
| 341 | } |
| 342 | else |
| 343 | { |
| 344 | $output .= "<div style='color:#000;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->uri->uri_string."</div>"; |
| 345 | } |
| 346 | |
| 347 | $output .= "</fieldset>"; |
| 348 | |
| 349 | return $output; |
| 350 | } |
| 351 | |
| 352 | // -------------------------------------------------------------------- |
| 353 | |
| 354 | /** |
| 355 | * Show the controller and function that were called |
| 356 | * |
| 357 | * @access private |
| 358 | * @return string |
| 359 | */ |
| 360 | function _compile_controller_info() |
| 361 | { |
| 362 | $output = "\n\n"; |
| 363 | $output .= '<fieldset style="border:1px solid #995300;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; |
| 364 | $output .= "\n"; |
| 365 | $output .= '<legend style="color:#995300;"> '.$this->CI->lang->line('profiler_controller_info').' </legend>'; |
| 366 | $output .= "\n"; |
| 367 | |
| 368 | $output .= "<div style='color:#995300;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->router->fetch_class()."/".$this->CI->router->fetch_method()."</div>"; |
| 369 | |
| 370 | |
| 371 | $output .= "</fieldset>"; |
| 372 | |
| 373 | return $output; |
| 374 | } |
Derek Allard | 76af409 | 2010-01-16 19:20:49 +0000 | [diff] [blame] | 375 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 376 | // -------------------------------------------------------------------- |
| 377 | |
| 378 | /** |
| 379 | * Compile memory usage |
| 380 | * |
| 381 | * Display total used memory |
| 382 | * |
| 383 | * @access public |
| 384 | * @return string |
| 385 | */ |
| 386 | function _compile_memory_usage() |
| 387 | { |
| 388 | $output = "\n\n"; |
| 389 | $output .= '<fieldset style="border:1px solid #5a0099;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; |
| 390 | $output .= "\n"; |
| 391 | $output .= '<legend style="color:#5a0099;"> '.$this->CI->lang->line('profiler_memory_usage').' </legend>'; |
| 392 | $output .= "\n"; |
| 393 | |
| 394 | if (function_exists('memory_get_usage') && ($usage = memory_get_usage()) != '') |
| 395 | { |
| 396 | $output .= "<div style='color:#5a0099;font-weight:normal;padding:4px 0 4px 0'>".number_format($usage).' bytes</div>'; |
| 397 | } |
| 398 | else |
| 399 | { |
Derek Allard | 76af409 | 2010-01-16 19:20:49 +0000 | [diff] [blame] | 400 | $output .= "<div style='color:#5a0099;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_memory_usage')."</div>"; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 401 | } |
| 402 | |
| 403 | $output .= "</fieldset>"; |
| 404 | |
| 405 | return $output; |
| 406 | } |
| 407 | |
| 408 | // -------------------------------------------------------------------- |
| 409 | |
| 410 | /** |
Derek Allard | 76af409 | 2010-01-16 19:20:49 +0000 | [diff] [blame] | 411 | * Compile header information |
| 412 | * |
| 413 | * Lists HTTP headers |
| 414 | * |
| 415 | * @access public |
| 416 | * @return string |
| 417 | */ |
| 418 | function _compile_http_headers() |
| 419 | { |
| 420 | $output = "\n\n"; |
| 421 | $output .= '<fieldset style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; |
| 422 | $output .= "\n"; |
| 423 | $output .= '<legend style="color:#000;"> '.$this->CI->lang->line('profiler_headers').' </legend>'; |
| 424 | $output .= "\n"; |
| 425 | |
| 426 | $output .= "\n\n<table cellpadding='4' cellspacing='1' border='0' width='100%'>\n"; |
| 427 | |
Derek Jones | 079303e | 2010-03-02 18:16:23 -0600 | [diff] [blame] | 428 | foreach(array('HTTP_ACCEPT', 'HTTP_USER_AGENT', 'HTTP_CONNECTION', 'SERVER_PORT', 'SERVER_NAME', 'REMOTE_ADDR', 'SERVER_SOFTWARE', 'HTTP_ACCEPT_LANGUAGE', 'SCRIPT_NAME', 'REQUEST_METHOD',' HTTP_HOST', 'REMOTE_HOST', 'CONTENT_TYPE', 'SERVER_PROTOCOL', 'QUERY_STRING', 'HTTP_ACCEPT_ENCODING', 'HTTP_X_FORWARDED_FOR') as $header) |
Derek Allard | 76af409 | 2010-01-16 19:20:49 +0000 | [diff] [blame] | 429 | { |
| 430 | $val = (isset($_SERVER[$header])) ? $_SERVER[$header] : ''; |
| 431 | $output .= "<tr><td valign='top' style='color:#900;background-color:#ddd;'>".$header." </td><td style='color:#000;background-color:#ddd;'>".$val."</td></tr>\n"; |
| 432 | } |
| 433 | |
| 434 | $output .= "</table>\n"; |
| 435 | $output .= "</fieldset>"; |
| 436 | |
| 437 | $output .= "</fieldset>"; |
| 438 | |
| 439 | return $output; |
| 440 | } |
| 441 | |
| 442 | // -------------------------------------------------------------------- |
| 443 | |
| 444 | /** |
| 445 | * Compile config information |
| 446 | * |
| 447 | * Lists developer config variables |
| 448 | * |
| 449 | * @access public |
| 450 | * @return string |
| 451 | */ |
| 452 | function _compile_config() |
| 453 | { |
| 454 | $output = "\n\n"; |
| 455 | $output .= '<fieldset style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; |
| 456 | $output .= "\n"; |
| 457 | $output .= '<legend style="color:#000;"> '.$this->CI->lang->line('profiler_config').' </legend>'; |
| 458 | $output .= "\n"; |
| 459 | |
| 460 | $output .= "\n\n<table cellpadding='4' cellspacing='1' border='0' width='100%'>\n"; |
| 461 | |
| 462 | foreach($this->CI->config->config as $config=>$val) |
| 463 | { |
| 464 | $output .= "<tr><td valign='top' style='color:#900;background-color:#ddd;'>".$config." </td><td style='color:#000;background-color:#ddd;'>".$val."</td></tr>\n"; |
| 465 | } |
| 466 | |
| 467 | $output .= "</table>\n"; |
| 468 | $output .= "</fieldset>"; |
| 469 | |
| 470 | $output .= "</fieldset>"; |
| 471 | |
| 472 | return $output; |
| 473 | } |
| 474 | |
| 475 | // -------------------------------------------------------------------- |
| 476 | |
| 477 | /** |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 478 | * Run the Profiler |
| 479 | * |
| 480 | * @access private |
| 481 | * @return string |
| 482 | */ |
| 483 | function run() |
| 484 | { |
| 485 | $output = "<div id='codeigniter_profiler' style='clear:both;background-color:#fff;padding:10px;'>"; |
Derek Jones | ee71c80 | 2010-03-10 10:05:05 -0600 | [diff] [blame^] | 486 | $fields_displayed = 0; |
| 487 | |
| 488 | foreach ($this->_available_sections as $section) |
| 489 | { |
| 490 | if ($this->_compile_{$section} !== FALSE) |
| 491 | { |
| 492 | $func = "_compile_{$section}"; |
| 493 | $output .= $this->{$func}(); |
| 494 | $fields_displayed++; |
| 495 | } |
| 496 | } |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 497 | |
Derek Jones | ee71c80 | 2010-03-10 10:05:05 -0600 | [diff] [blame^] | 498 | if ($fields_displayed == 0) |
| 499 | { |
| 500 | $output .= '<p style="border:1px solid #5a0099;padding:10px;margin:20px 0;background-color:#eee">'.$this->CI->lang->line('profiler_no_profiles').'</p>'; |
| 501 | } |
| 502 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 503 | $output .= '</div>'; |
| 504 | |
| 505 | return $output; |
| 506 | } |
| 507 | |
| 508 | } |
| 509 | |
| 510 | // END CI_Profiler class |
| 511 | |
| 512 | /* End of file Profiler.php */ |
Derek Jones | a3ffbbb | 2008-05-11 18:18:29 +0000 | [diff] [blame] | 513 | /* Location: ./system/libraries/Profiler.php */ |