opcode看PHP代码性能有关问题之疑惑

WBOY
Release: 2016-06-13 13:20:20
Original
1000 people have browsed it

opcode看PHP代码性能问题之疑惑

最近在看到《?一些PHP Coding Tips》中提到一点:避免在for判断条件中做运算。

?

于是兴起用vld看了一下:


for ($i=0; $i


for($i=0, $j=strlen($str); $i


opcode:


$name = "xiaoshenge";
for ($i = 0; $i 
Copy after login

?

$name = "xiaoshenge";
for ($i = 0, $j = strlen($name); $i 
?
<p><br><img alt="" src="http://www.daimami.com/img/2014/01/01/1605161658.bmp"></p>
<p>由此来看的opcode区别还真看不出来,所以我有点怀疑之前看到的文章用opcode来看PHP代码的性能问题,于是发邮件请假了几个前辈,但是只有一个看到并且回复我了。</p>
<p>?</p>
<p>?</p>
<p>其中reeze.xia@gmail.com(http://www.phppan.com/)是怎么回复的:</p>
<p>?</p>
<p>这两者的opcode相近也是可以理解的,opcode相当于只是把需要进行的操作翻译了一下,
</p>
<p>不过我们直观的从代码也能看出两者的却别,后者需要进行的计算会小点,不过这只是从直观看的,</p>
<p>最终我们还是需要自己做个性能测试验证一下,因为性能涉及到的内容太广了,</p>
<p>Zend引擎本身可能会对操作进行优化,CPU自己也会有自己的优化,这些都可能都会影响到我们的性能:)</p>
<p><br></p>
<p>所以,php的opcode还不是类似C的编译后的可执行文件,单纯用opcode分享代码执行效率还是有点问题的...</p>

<p>?</p>
<p>?</p>
 <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!