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, $ environmen PHP simple performance detection tools.
I. OverviewThis class mainly detects the running time of a piece of code and some PHP efficiency problems.
II. usageFirst, the require class mainly uses the interfaces begin (), preTime () and end () begin ($ output, $ environment). This interface is mainly used to detect the initial position. when this interface is executed, it indicates that the detection starts. PreTime () this interface is mainly 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 purposesYou 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