PHP performance testing tools

Source: Internet
Author: User
PHP simple performance testing tools I. Overview & nbsp; this class mainly detects the running time of a piece of code and some PHP efficiency problems. II. usage first, The require class mainly uses the interfaces begin (), preTime () and end () begin ($ output, $ environment) to detect the initial position, when this interface is executed, the detection starts. Pre PHP simple performance testing tools

I. Overview

This class mainly detects the running time of a piece of code and some PHP efficiency problems.


II. usage

First, the require class

The main interfaces are begin (), preTime (), and end ()

Begin ($ output, $ environment)

This interface is mainly used to detect the initial position. when this interface is executed, the detection starts.

PreTime ()

This interface is used to detect the last code execution time.

End ()

This interface is mainly used to detect the total execution time


III. example

  1. Require "run_time_test.php ";
  2. Run_Time_Test: begin (true );
  3. $ A = "";
  4. $ B = "";
  5. For ($ I = 0; I I <10000; $ I ++ ){
  6. $ A. = $ I;
  7. }
  8. Run_Time_Test: preTime ();
  9. For ($ I = 0; I I <10000; $ I ++ ){
  10. $ B. = $ I;
  11. }
  12. Run_Time_Test: end ();


Load the tool class, set the detection start position, add multiple Run_Time_Test: preTime () in the code, check the code execution efficiency of each stage, and finally output the total running time.


IV. main purposes

You can add "begin" and "end" at the PHP Portal and "end" at the output. you can add two Run_Time_Test: preTime (); to test the efficiency and record the execution results to the info log. This allows you to view the code execution efficiency, especially when some algorithms are being executed.


Click here to test code and classes

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.