blob: 026bfac602c778e266b47c9bb4e6e1a73302810d [file] [log] [blame]
admind13ff072006-10-03 03:40:45 +00001<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
2/**
3 * Code Igniter
4 *
5 * An open source application development framework for PHP 4.3.2 or newer
6 *
7 * @package CodeIgniter
8 * @author Rick Ellis
9 * @copyright Copyright (c) 2006, pMachine, Inc.
10 * @license http://www.codeignitor.com/user_guide/license.html
11 * @link http://www.codeigniter.com
12 * @since Version 1.0
13 * @filesource
14 */
15
16// ------------------------------------------------------------------------
17
18/**
19 * Code Igniter 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 * @package CodeIgniter
25 * @subpackage Libraries
26 * @category Libraries
27 * @author Rick Ellis
28 * @link http://www.codeigniter.com/user_guide/libraries/benchmark.html
29 */
30class CI_Profiler {
31
32
33 // --------------------------------------------------------------------
34
35 /**
36 * Auto Profiler
37 *
38 * This function cycles through the entire array of mark points and
39 * matches any two points that are named identially (ending in "_start"
40 * and "_end" respectively). It then compiles the execution times for
41 * all points and returns it as an array
42 *
43 * @access private
44 * @return array
45 */
46 function _compile_benchmarks()
47 {
48 $obj =& get_instance();
49
50 $times = array();
51 foreach ($obj->benchmark->marker as $key => $val)
52 {
53 // We match the "end" marker so that the list ends
54 // up in the order that it was defined
55 if (preg_match("/(.+?)_end/i", $key, $match))
56 {
57 if (isset($obj->benchmark->marker[$match[1].'_end']))
58 {
59 $times[$match[1]] = $obj->benchmark->elapsed_time($match[1].'_start', $key);
60 }
61 }
62 }
63
64 return $times;
65 }
66
67 // --------------------------------------------------------------------
68
69}
70
71// END CI_Profiler class
72?>