thinkphp Development Framework function Detailed: G Method of gorgeous upgrade

Source: Internet
Author: User
Keywords Development framework function G method thinkphp
Tags aliyun cost debug development development framework environment example framework

Thinkphp has long needed to function through Debug_start, debug_end methods, and even http://www.aliyun.com/zixun/aggregation/10818.html ">debug classes, The 3.1 version is replaced by a simple G method, which cannot be said to be a gorgeous upgrade.
The G method's function includes the mark position and the interval statistic two function, below see the concrete usage:

Mark Position

The first use of the G method is to mark the location, for example:

G (' begin ');

Indicates that the current position is marked as a begin label, and the execution time of the current position is recorded, and memory consumption can be logged if the environment supports it. The G method tag can be invoked at any location.

Run Time statistics

After marking the position, we can call the G method again for interval statistics, for example:

G (' begin '); // ... Other code Snippet G (' End '); // ... Maybe there's another code here//For statistical interval echo G (' Begin ', ' end '). S ';

G (' Begin ', ' End ') indicates the execution time (in seconds) of the statistic begin position to the end position, and the beginning must be a marked position, and if the ends are not marked at this time, the current position is automatically marked as the last label, and the output is similar to the following:

0.0056s

The default statistic precision is 4 digits after the decimal point, and if 211.html ">" feels this statistic is not accurate enough, you can also set up for example:

G (' Begin ', ' End ', 6). ' S ';

The possible output becomes:

0.005587s

Memory Cost Statistics

If your environment supports memory footprint statistics, you can also use the G method for interval memory cost statistics (in kilobytes), for example:

echo G (' Begin ', ' End ', ' m '). KB ';

The third parameter uses m to represent the memory cost statistics, and the output may be:

625kb

Similarly, if the end tag is not marked, the current position is automatically marked with the first bit of the label.
If the environment does not support memory statistics, the parameter is invalid, and interval running time statistics are still performed.
Forget Debug_start, Debug_end, Boulevard to Jane, you know

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