└── manager /manager: -------------------------------------------------------------------------------- 1 | marker[$name] = microtime(TRUE); 74 | } 75 | 76 | // -------------------------------------------------------------------- 77 | 78 | /** 79 | * Elapsed time 80 | * 81 | * Calculates the time difference between two marked points. 82 | * 83 | * If the first parameter is empty this function instead returns the 84 | * {elapsed_time} pseudo-variable. This permits the full system 85 | * execution time to be shown in a template. The output class will 86 | * swap the real value for this variable. 87 | * 88 | * @param string $point1 A particular marked point 89 | * @param string $point2 A particular marked point 90 | * @param int $decimals Number of decimal places 91 | * 92 | * @return string Calculated elapsed time on success, 93 | * an '{elapsed_string}' if $point1 is empty 94 | * or an empty string if $point1 is not found. 95 | */ 96 | public function elapsed_time($point1 = '', $point2 = '', $decimals = 4) 97 | { 98 | if ($point1 === '') 99 | { 100 | return '{elapsed_time}'; 101 | } 102 | 103 | if ( ! isset($this->marker[$point1])) 104 | { 105 | return ''; 106 | } 107 | 108 | if ( ! isset($this->marker[$point2])) 109 | { 110 | $this->marker[$point2] = microtime(TRUE); 111 | } 112 | 113 | return number_format($this->marker[$point2] - $this->marker[$point1], $decimals); 114 | } 115 | 116 | // -------------------------------------------------------------------- 117 | 118 | /** 119 | * Memory Usage 120 | * 121 | * Simply returns the {memory_usage} marker. 122 | * 123 | * This permits it to be put it anywhere in a template 124 | * without the memory being calculated until the end. 125 | * The output class will swap the real value for this variable. 126 | * 127 | * @return string '{memory_usage}' 128 | */ 129 | public function memory_usage() 130 | { 131 | return '{memory_usage}'; 132 | } 133 | 134 | } 135 | --------------------------------------------------------------------------------