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