Php script execution time statistics (phpscriptexecutiontimestatistics)

Source: Internet
Author: User
This project is the script execution time statistics used by "which mobile accounting is spent" and is published to share with the open-source community. This project is used to analyze the PHP script execution time recorded in the log and draw a Statistical Chart for reference by background developers. By observing charts, developers can locate slow PHP scripts to optimize PHP scripts. Day

This project is the script execution time statistics used by "which mobile accounting is spent" and is published to share with the open-source community. This project is used to analyze the PHP script execution time recorded in the log and draw a Statistical Chart for reference by background developers. By observing charts, developers can locate slow PHP scripts to optimize PHP scripts. Day

This project is the script execution time statistics used by "which mobile accounting is spent" and is published to share with the open-source community. This project is used to analyze the PHP script execution time recorded in the log and draw a Statistical Chart for reference by background developers. By observing charts, developers can locate slow PHP scripts to optimize PHP scripts.

Log format:
0.001626 @/var/www/path/3g/cost. php @ show_cost_page @ 1312106318
0.00266 @/var/www/path/3g/cost. php @ show_day_info @ 1312106320
0.001099 @/var/www/path/3g/setting. php @ setting @ 1312106321
Fields separated by "@" represent the script execution time, script file path, script execution end point, and the UNIX timestamp at that time. PHP

Source code and demo:Source code

 Begin_time = gettimeofday ();} public function script_over ($ end_point) {$ tmp = gettimeofday (); $ time = ($ tmp ["usec"]-$ this-> begin_time ["usec"])/1000000; $ file = fopen ("exec_time.txt ", "a +"); $ this-> I ++; // write the script execution time to the log file fwrite ($ file, $ time. "@". $ _ SERVER ["SCRIPT_FILENAME"]. "@". $ end_point. "@". $ tmp ["sec"]. "\ n"); fclose ($ file) ;}}?>
// Record the execution time of the script (/var/www/path/3g/setting. php:
 Script_over ("record_cost");?> // Php script execution time statistics, format define and result display in web.

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.