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
-
- Require "run_time_test.php ";
-
- Run_Time_Test: begin (true );
-
- $ A = "";
- $ B = "";
- For ($ I = 0; I I <10000; $ I ++ ){
- $ A. = $ I;
- }
-
- Run_Time_Test: preTime ();
-
- For ($ I = 0; I I <10000; $ I ++ ){
- $ B. = $ I;
- }
-
- 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