CI framework source code reading --------- Benchmark test class Benchmark. php & lt ;? Phpif (! Defined (BASEPATH) exit (Nodirectscriptaccessallowed); *** CodeIgniter *** Anopensourceapplicationdevelopmentfram CI framework source code reading --------- Benchmark test class Benchmark. php
Marker [$ name] = microtime ();} // --------------------------------/*** Calculates the time difference between two marked points. * calculate the time between two time points. * If the first parameter is empty this function instead returns the * {elapsed_time} pseudo-variable false 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. ** @ accesspublic * @ paramstringa pays point * @ paramintegerthe number of decimal places * @ returnmix Ed */function elapsed_time ($ point1 = '', $ point2 ='', $ decimals = 4) {/** if no specific time point is provided, then the accountant calculates the entire program running time. * How can we calculate the running time of the entire program? In fact, the Output component is used for this calculation. * When Benchmark: elapsed_time (); (no parameter) is called, the first response is not * the time of the entire program running, nor is it possible to do so, in essence, a {elapsed_time} tag is returned, and * Output calculates the entire program running time when processing the Output, because the program in the Output processing stage can regard * as in the final stage, therefore, we can calculate the total time and replace {elapsed_time} in the output. * Memory_usage () follows the same principle. */If ($ point1 = '') {return '{elapsed_time}';} if (! Isset ($ this-> marker [$ point1]) {return '';} if (! Isset ($ this-> marker [$ point2]) {$ this-> marker [$ point2] = microtime () ;}// why list is used here, because of microtime (); the returned value is in the format of "msec sec. List ($ sm, $ ss) = explode ('', $ this-> marker [$ point1]); list ($ em, $ es) = explode ('', $ this-> marker [$ point2]); return number_format ($ em + $ es)-($ sm + $ ss), $ decimals );} // --------------------------------/*** 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. ** @ accesspublic * @ returnstring */function memory_usage () {return '{memory_usage}' ;}}// END CI_Benchmark class/* End of file Benchmark. php * // * Location :. /system/core/Benchmark. php */