VII) CodeIgniter Source code Analysis of the benchmark.php

Source: Internet
Author: User

1<?phpif( !defined(' BasePath '))Exit(' No Direct script access allowed ');2 // ------------------------------------------------------------------------3 4 /**5 * CodeIgniter Benchmark Class6  */7 classCi_benchmark {8 9  /**Ten * List of all benchmark markers and when they were added One   */ A  var $marker=Array(); -  -  // -------------------------------------------------------------------- the  -  /** - * Set A benchmark marker -   */ +  functionMark$name) -  { +   //This method is very simple, that is, when invoking local law anywhere in the program, the current point in time is recorded.  A   $this->marker[$name] =Microtime(); at  } -  -  // -------------------------------------------------------------------- -  -  /** - * Calculates the time difference between and marked points. in * Calculates the time between two points in time.  -   */ to  functionElapsed_time ($point 1= ",$point 2= ",$decimals= 4) +  { -   /* the * If no definite point of time is given, then the time of the entire program 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 returning the first is notPanax Notoginseng * The entire program run time, also impossible to do, in essence, return is a {elapsed_time} tag, and then - * Output will calculate the entire program run time when processing the outputs, as the process output stage can be considered the * To be in the final phase, you can approximate the total time and then replace {elapsed_time} in the output.  + * the following memory_usage () principle is the same.  A * See: The _display () method in core/output.php.  the    */ +   if($point 1= = "') -   { $    return' {elapsed_time} '; $   } -  -   if( !isset($this->marker[$point 1])) the   { -    return‘‘;Wuyi   } the  -   if( !isset($this->marker[$point 2])) Wu   { -    $this->marker[$point 2] =Microtime(); About   } $  -   //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]); A  +   return Number_format(($em+$es) - ($SM+$ss),$decimals); the  } -  $  // -------------------------------------------------------------------- the  the  /** the * Memory Usage the   */ -  functionmemory_usage () in  { the   //Output::_display (); the   return' {memory_usage} '; About  } the  the}

VII) CodeIgniter Source code Analysis of the 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.