CI framework source code reading --------- Benchmark test class Benchmark. php

Source: Internet
Author: User
[Php] & lt ;? Phpif (! Defined (& amp; #39; BASEPATH & amp; #39;) exit (& amp; #39; Nodirectscriptaccessallowed & amp; #39 ;); /*** CodeIgniter *** Anopensourceapplicatio [php] Marker [$ name] = microtime ();} // calculate/*** 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. ** @ access public * @ param string a participant marked point * @ param integer the number of decimal places * @ re Turn mixed */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. * www.2cto.com * @ access public * @ return string */function memory_usage () {return '{memory_usage}' ;}}// END CI_Benchmark class/* End of file Benchmark. php * // * Location :. /system/core/Benchmark. php */

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.