CI Framework source Reading---------Benchmark Class benchmark.php_php tutorial

Source: Internet
Author: User
Tags codeigniter
[PHP] marker[$name] = Microtime (); }//--------------------------------------------------------------------/** * Calculates the time difference between The 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. * * @access public * @param string a particular marked point * @param string a particular marked point * @param integer th E Number of decimal places * @return Mixed */function elapsed_time ($point 1 = ", $point 2 =", $decimals = 4) {/* * if not Given a definite point in time, the duration of the entire program's run is calculated. * 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[$poi Nt2] = Microtime (); }//Why list is used here because Microtime (); The return value is in the format "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. * * @access public * @return String */function Memory_usage () {return ' {memory_usage} ';} End Ci_benchmark class/* End of File benchmark.php */* location:./system/core/benchmark.php */ true techarticle [PHP]-PHP if (! defined (BasePath)) exit (No Direct script access allowed);/** * CodeIgniter * * An open source appli Cation development framework for PHP 5.1.6 or newer * * @packag ...

  • Related Article

    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: 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.