Does the PHP _ autoload () method affect performance?

Source: Internet
Author: User

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. Some netizens say that the maintenance cost is countless times higher than the performance cost due to the NO _ autoload () (I agree ).
 
Environment
 
PHP: 5.3.9 -- started in fastcgi Mode
Nginx: 1.1.12
Eaccelerator: 0.9.6.1
 
:

 
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 with eAccelerator Cache
 
Test code: loaded by _ autoload


 
Figure 1
The refresh results 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: Without _ autoload ()

 

Figure 2

Test result-click the browser
Total Time: 0.10309100151062
Total Time: 0.10285210609436
Total Time: 0.10154414176941
Total Time: 0.097845792770386
Total Time: 0.099545001983643
Total Time: 0.10166597366333
 
The final result is that the autoload method does not show significant performance degradation.
 
Test: cancel the eAccelerator cache for testing
 
Test results 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
 
Test results in Figure 2
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.

Summary
 
The above two groups of experiments show that:
1 >__ the 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.
 


From Chuan Shan Jia

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.