Introduction
For php performance problems, the _ autoload () method is the most widely discussed method. Many people have mentioned that this method has a great impact on performance. Some people say that opcode can also affect the _ autoload () method, so I did a test for these two points.
In the end, we found that the _ autoload method has little impact on the performance.
Environment
PHP: 5.3.9 -- started in fastcgi Mode
Nginx: 1.1.12
Eaccelerator: 0.9.6.1
.
In the end, we found that the _ autoload method has little impact on the performance. Environment PHP: 5.3.9 -- start Nginx: 1.1.12 eaccelerator: 0.9.6.1 in fastcgi mode:
Startup interface:
EAccelerator (in the php. ini file) Configuration:
File structure: (each Test file is a file with more than 6000 lines of code)
Test: Test code with eAccelerator cache: loaded by _ autoload
Figure 1
The results obtained by refreshing in the browser are as follows: Total Time: 0.10401391983032 Total Time: 0.10252094268799 Total Time: 0.095267057418823 Total Time: 0.10013008117676 Total Time: 0.096842050552368 Total Time: 0.097998142242432 Total Time: 0.10348510742188 Total Time: 0.096648931503296 test: not passed _ autoload ()
Figure 2
Test result -- the final result is displayed by refreshing the browser Total Time: 0.10309100151062 Total Time: 0.10285210609436 Total Time: 0.10154414176941 Total Time: 0.097845792770386 Total Time: 0.099545001983643: the autoload method does not show significant performance degradation tests: cancel the eAccelerator cache and test the test result in Figure 1. Total Time: 0.24992394447327 Total Time: 0.25681900978088 Total Time: 0.25327301025391 Total Time: 0.22580695152283 Total Time: 0.22656512260437 Total Time: 0.22530484199524 Total Time: 0.23080611228943 Fig 2 Test Result Total Time: 0.23054909706116 Total Time: 0.22633790969849 Total Time: 0.23442888259888 Total Time: 0.2350070476532 Total Time: 0.22897601127625 Total Time: 0.23207712173462
The _ autoload () method does not significantly affect the performance.
Conclusion: The above two groups of experiments show that the 1 >__ autoload method has no obvious performance loss. Therefore, do not use the _ autoload method. 2> when opcode is used, php code execution speed is significantly improved by more than twice.