CI_Benchmark Class Reference

List of all members.


Public Member Functions

 mark ($name)
 Set a benchmark marker.
 elapsed_time ($point1= '', $point2= '', $decimals=4)
 Calculates the time difference between two marked points.
 memory_usage ()
 Memory Usage.

Public Attributes

 $marker = array()

Detailed Description

Definition at line 30 of file Benchmark.php.


Member Function Documentation

CI_Benchmark::elapsed_time ( point1 = '',
point2 = '',
decimals = 4 
)

Calculates the time difference between two marked points.

If the first parameter is empty this function instead returns the {elapsed_time} pseudo-variable. This permits the full system execution time to be shown in a template. The output class will swap the real value for this variable.

public

Parameters:
string a particular marked point
string a particular marked point
integer the number of decimal places
Returns:
mixed

Definition at line 67 of file Benchmark.php.

00068         {
00069                 if ($point1 == '')
00070                 {
00071                         return '{elapsed_time}';
00072                 }
00073 
00074                 if ( ! isset($this->marker[$point1]))
00075                 {
00076                         return '';
00077                 }
00078 
00079                 if ( ! isset($this->marker[$point2]))
00080                 {
00081                         $this->marker[$point2] = microtime();
00082                 }
00083         
00084                 list($sm, $ss) = explode(' ', $this->marker[$point1]);
00085                 list($em, $es) = explode(' ', $this->marker[$point2]);
00086 
00087                 return number_format(($em + $es) - ($sm + $ss), $decimals);
00088         }

CI_Benchmark::mark ( name  ) 

Set a benchmark marker.

Multiple calls to this function can be made so that several execution points can be timed

public

Parameters:
string $name name of the marker
Returns:
void

Definition at line 46 of file Benchmark.php.

00047         {
00048                 $this->marker[$name] = microtime();
00049         }

CI_Benchmark::memory_usage (  ) 

Memory Usage.

This function returns the {memory_usage} pseudo-variable. This permits it to be put it anywhere in a template without the memory being calculated until the end. The output class will swap the real value for this variable.

public

Returns:
string

Definition at line 103 of file Benchmark.php.

00104         {
00105                 return '{memory_usage}';
00106         }


Member Data Documentation

CI_Benchmark::$marker = array()

Definition at line 32 of file Benchmark.php.


The documentation for this class was generated from the following file: