1 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
5 * An open source application development framework for PHP 5.1.6 or newer
8 * @author ExpressionEngine Dev Team
9 * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
10 * @license http://codeigniter.com/user_guide/license.html
11 * @link http://codeigniter.com
16 // ------------------------------------------------------------------------
19 * CodeIgniter Benchmark Class
21 * This class enables you to mark points and calculate the time difference
22 * between them. Memory consumption can also be displayed.
24 * @package CodeIgniter
25 * @subpackage Libraries
27 * @author ExpressionEngine Dev Team
28 * @link http://codeigniter.com/user_guide/libraries/benchmark.html
32 var $marker = array();
34 // --------------------------------------------------------------------
37 * Set a benchmark marker
39 * Multiple calls to this function can be made so that several
40 * execution points can be timed
43 * @param string $name name of the marker
48 $this->marker[$name] = microtime();
51 // --------------------------------------------------------------------
54 * Calculates the time difference between two marked points.
56 * If the first parameter is empty this function instead returns the
57 * {elapsed_time} pseudo-variable. This permits the full system
58 * execution time to be shown in a template. The output class will
59 * swap the real value for this variable.
62 * @param string a particular marked point
63 * @param string a particular marked point
64 * @param integer the number of decimal places
67 function elapsed_time($point1 = '', $point2 = '', $decimals = 4)
71 return '{elapsed_time}';
74 if ( ! isset($this->marker[$point1]))
79 if ( ! isset($this->marker[$point2]))
81 $this->marker[$point2] = microtime();
84 list($sm, $ss) = explode(' ', $this->marker[$point1]);
85 list($em, $es) = explode(' ', $this->marker[$point2]);
87 return number_format(($em + $es) - ($sm + $ss), $decimals);
90 // --------------------------------------------------------------------
95 * This function returns the {memory_usage} pseudo-variable.
96 * This permits it to be put it anywhere in a template
97 * without the memory being calculated until the end.
98 * The output class will swap the real value for this variable.
103 function memory_usage()
105 return '{memory_usage}';
110 // END CI_Benchmark class
112 /* End of file Benchmark.php */
113 /* Location: ./system/core/Benchmark.php */