Php running Status Report tool: php-timer

Source: Internet
Author: User
Php running Status Report tool: php-timer recently wrote an asynchronous mysql client encapsulation to compare the performance with the traditional serial method. Including the running time, memory usage, and other information. Searching on github and packagist does not find what you want. xhprof is too large and the results are too complex to meet your current needs. Therefore, you have to write a package to monitor the running time and memory usage of the php script and generate a report.

Sample code:

Requiredirname (dirname (_ FILE __)). DIRECTORY_SEPARATOR. 'endand '. DIRECTORY_SEPARATOR. 'autoload. php '; // initialization, set the memory unit $ timer = new \ Jenner \ Timer (\ Jenner \ Timer: UNIT_KB ); // record a status $ timer-> mark ('A'); sleep (2); // record B status $ timer-> mark ('B '); sleep (3); // records the c state $ timer-> mark ('C'); sleep (4 ); // record d status $ timer-> mark ('D'); // Print the overall report (excluding the difference value) $ timer-> printReport (); // Obtain the overall report, returns the array $ report = $ timer-> getReport (); // gets the report of a mark $ a_report = $ timer-> getReport ('A'); print_r ($ a_report ); // Print the differences between the and B statuses, including the running time and memory usage $ timer-> printDiffReportByStartAndEnd ('A', 'B '); // Obtain the report on the differences between Status a and status B $ AB _diff_report = $ timer-> getDiffReportByStartAndEnd ('A', 'B '); // Print the difference between the first mark and the last mark $ timer-> printDiffReport (); // Obtain the difference between the first mark and the last mark $ diff_report = $ timer-> getDiffReport ();

Output result:

 ------------------------------------------mark:atime:1437535424.9998smemory_real:1280KBmemory_emalloc:833.046875KBmemory_peak_real:1280KBmemory_peak_emalloc:843.2890625KB------------------------------------------mark:btime:1437535427smemory_real:1280KBmemory_emalloc:834.2265625KBmemory_peak_real:1280KBmemory_peak_emalloc:843.2890625KB------------------------------------------mark:ctime:1437535430.0002smemory_real:1280KBmemory_emalloc:835.1875KBmemory_peak_real:1280KBmemory_peak_emalloc:843.2890625KB------------------------------------------mark:dtime:1437535434.0004smemory_real:1280KBmemory_emalloc:836.1484375KBmemory_peak_real:1280KBmemory_peak_emalloc:843.2890625KBArray(    [time] => 1437535424.9998    [memory_real] => 1310720    [memory_emalloc] => 853040    [memory_peak_real] => 1310720    [memory_peak_emalloc] => 863528)------------------------------------------mark:[diff] start_mark:a end_mark:btime:2.0001850128174smemory_real:0KBmemory_emalloc:1.1796875KBmemory_peak_real:0KBmemory_peak_emalloc:0KB------------------------------------------mark:[totaldiff]time:9.0006000995636smemory_real:0KBmemory_emalloc:3.1015625KBmemory_peak_real:0KBmemory_peak_emalloc:0KB

Project homepage:Http://www.open-open.com/lib/view/home/1437969396019

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.