CI Framework source Reading---------Benchmark test class benchmark.php
marker[$name] = Microtime ();} --------------------------------/** * Calculates the time difference between, marked points. * Calculates the time between two points in time. * If The first parameter is empty this function instead returns the * {Elapsed_time} pseudo-variable false variable. This permits license for the full system * Execution time to being shown in a template. The output class would * swap the real value for this variable. * * @accesspublic * @paramstringa particular marked point * @paramstringa particular marked point * @paramintegerthe Numbe R of decimal places * @returnmixed */function elapsed_time ($point 1 = ", $point 2 =", $decimals = 4) {/* * If no definite point of time is given, then Calculates the time the entire program is running. * How can we calculate the running time of the whole program? In fact, this calculation is performed by the output component. * While calling Benchmark::elapsed_time (), (no arguments), essentially the first thing to return is not the time of the whole program to run, or the actual return is a {elapsed_time} tag, and then * output in the processing of outputs, Calculate the entire program run time, because the processing output stage program can be considered as the last stage, so can approximate the total time, and then the output of {elapsed_time} replaced. * the following memory_usage () principle is the same. */if ($point 1 = = ") {return ' {elapsed_time} ';} if (! isset ($this->marker[$point 1])) {RetuRN ";} if (! isset ($this->marker[$point 2])) {$this->marker[$point 2] = Microtime ();} Why this list is used here is because Microtime (); The return value is the format of "msec sec". List ($SM, $ss) = Explode (", $this->marker[$point 1]), List ($em, $es) = Explode (", $this->marker[$point 2]); return Number_format (($em + $es)-($SM + $ss), $decimals);} --------------------------------/** * Memory Usage * * This function returns the {memory_usage} pseudo-variable. * This permits it is put it anywhere in a template * without the memory being calculated until the end. * The output class would swap the real value for this variable. * * @accesspublic * @returnstring */function memory_usage () {return ' {memory_usage} ';}} End Ci_benchmark class/* end of file benchmark.php *//* location:./system/core/benchmark.php */