Home Backend Development PHP Tutorial opcode看PHP代码性能有关问题之疑惑

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

Jun 13, 2016 pm 01:20 PM
for name strlen

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 src="/static/imghw/default1.png" data-src="http://www.daimami.com/img/2014/01/01/1605161658.bmp" class="lazy" alt=""></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
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1668
14
PHP Tutorial
1273
29
C# Tutorial
1256
24
17 ways to solve the kernel_security_check_failure blue screen 17 ways to solve the kernel_security_check_failure blue screen Feb 12, 2024 pm 08:51 PM

Kernelsecuritycheckfailure (kernel check failure) is a relatively common type of stop code. However, no matter what the reason is, the blue screen error causes many users to be very distressed. Let this site carefully introduce 17 types to users. Solution. 17 solutions to kernel_security_check_failure blue screen Method 1: Remove all external devices When any external device you are using is incompatible with your version of Windows, the Kernelsecuritycheckfailure blue screen error may occur. To do this, you need to unplug all external devices before trying to restart your computer.

How to uninstall Skype for Business on Win10? How to completely uninstall Skype on your computer How to uninstall Skype for Business on Win10? How to completely uninstall Skype on your computer Feb 13, 2024 pm 12:30 PM

Can Win10 skype be uninstalled? This is a question that many users want to know, because many users find that this application is included in the default program on their computers, and they are worried that deleting it will affect the operation of the system. Let this website help users Let’s take a closer look at how to uninstall Skype for Business in Win10. How to uninstall Skype for Business in Win10 1. Click the Windows icon on the computer desktop, and then click the settings icon to enter. 2. Click "Apply". 3. Enter "Skype" in the search box and click to select the found result. 4. Click "Uninstall". 5

How to use for to find the factorial of n in JavaScript How to use for to find the factorial of n in JavaScript Dec 08, 2021 pm 06:04 PM

How to use for to find n factorial: 1. Use the "for (var i=1;i<=n;i++){}" statement to control the loop traversal range to "1~n"; 2. In the loop body, use "cj *=i" Multiply the numbers from 1 to n, and assign the product to the variable cj; 3. After the loop ends, the value of the variable cj is the factorial of n, and then output it.

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 Jun 13, 2016 am 10:23 AM

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

What is the difference between foreach and for loop What is the difference between foreach and for loop Jan 05, 2023 pm 04:26 PM

Difference: 1. for loops through each data element through the index, while forEach loops through the data elements of the array through the JS underlying program; 2. for can terminate the execution of the loop through the break keyword, but forEach cannot; 3. for can control the execution of the loop by controlling the value of the loop variable, but forEach cannot; 4. for can call loop variables outside the loop, but forEach cannot call loop variables outside the loop; 5. The execution efficiency of for is higher than forEach.

How to avoid exceptions in simple for loops in JAVA? How to avoid exceptions in simple for loops in JAVA? Apr 26, 2023 pm 12:58 PM

Introduction In actual business project development, everyone should be familiar with the operation of removing elements that do not meet the conditions from a given list, right? Many students can immediately think of many ways to achieve it, but are all the ways you think of harmless to humans and animals? Many seemingly normal operations are actually traps, and many novices may fall into them if they are not careful. If unfortunately, an exception is thrown and an error is reported when the code is running, this is a blessing. At least the code can be discovered and solved in time without an error being reported, but various strange problems appear inexplicably in the business logic. This is more tragic. Because if you don't pay attention to this problem, it may cause hidden dangers for subsequent business. So, what are the implementation methods? What implementations might

How to do sizeof and strlen parsing How to do sizeof and strlen parsing May 27, 2023 pm 12:05 PM

1.strlen function. What strlen does is just a counter. It starts scanning from a certain location in the memory (it can be the beginning of the string, a location in the middle, or even an uncertain memory area) until it encounters Until the first string terminator '\0', and then return the counter value. 2. The sizeof operator sizeof() returns the amount of memory occupied by the variable after it is declared, not the actual length. In addition, sizeof is not a function, but just an operator. 3. The difference between strlen and sizeof 3.1sizeof can use types as parameters, strlen can only use char* as parameters, and must be &

What are the common flow control structures in Python? What are the common flow control structures in Python? Jan 20, 2024 am 08:17 AM

What are the common flow control structures in Python? In Python, the flow control structure is an important tool used to determine the execution order of the program. They allow us to execute different blocks of code based on different conditions, or to execute a block of code repeatedly. The following will introduce common process control structures in Python and provide corresponding code examples. Conditional statements (if-else): Conditional statements allow us to execute different blocks of code based on different conditions. Its basic syntax is: if condition 1: #when condition

See all articles