OpCode to see the question of PHP code performance

Source: Internet
Author: User
OpCode to see the problem of PHP code performance

Recently seen in the "? some php Coding Tips mention one thing: avoid doing arithmetic in the for-judging condition.

?

So the rise with VLD looked at:


for ($i =0; $i<>< p=""><>


For ($i =0, $j =strlen ($STR), $i < $j, $i + +)


OpCode


$name = "Xiaoshenge"; for ($i = 0; $i < strlen ($name); $i + +) {    echo "1";}

?

$name = "Xiaoshenge"; for ($i = 0, $j = strlen ($name); $i < $j; $i + +) {    echo "1";}
?


From this point of view opcode difference really don't see, so I have a little doubt to see the article with opcode look at the performance of PHP code, so sent an email leave a few seniors, but only one to see and reply to me.

?

?

Which reeze.xia@gmail.com (http://www.phppan.com/) is how to reply:

?

The similarities and opcode of the two are understandable, opcode is equivalent to just translating the operations needed,

But we can intuitively see the two from the code, the latter need to do the calculation will be small, but this is only viewed from the straight,

In the end, we still need to do a performance test to verify, because the performance involved in the content is too wide,

The Zend engine itself may be optimized for operations, and the CPU itself will have its own optimizations, which can all affect our performance:)


Therefore, PHP opcode is not similar to C-compiled executable file, simply use opcode to share code execution efficiency is still a bit of a problem ...

?

?

  • Related Article

    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.