Is there any performance increase when using the latest PHP syntax?

With the latest version of PHP 5.4.x there will soon be 5.5, a lot of new syntax has appeared . I understand their significance in terms of code readability, less (er) input by the programmer, bug fixes, etc.

But I'm particularly interested in how important (if any) performance improvement is in terms of using this new syntax. Is the PHP interpreter and / or Zend engine faster / improved if more new syntax is used?

Or maybe I'm missing everything. You need your knowledge and thoughts about this. Thanks!

+4
source share
3 answers

New syntax is added to the language to simplify the writing of the program and simplify the organization of the code; usually don't do it better. You should not think about using specific syntax for performance reasons, but because it makes your code better, easier to work, easier to read, etc.

For example, PHP 5.5 introduces the Generator syntax ( yield keyword). This is an improved way to write iterators. But it will not provide a performance difference between writing Iterator style code; it will basically do the same under the hood. The important point is that it is much easier to write a simple generator than to write the same code using Iterator. The code is shorter, neater and more understandable. He will not work faster, but it will be much easier to work with him. It's all.

However, PHP does have a good track record that significantly improves language performance with each version. You don’t even need to use the new features - just upgrade to the latest version and you will get a performance boost from your existing code. In some cases, productivity can improve by 50% or more. Considering that the update should be no problem; the ability to use new language features is an added advantage over performance gains.

There are many criteria to prove this; here is one example that covers PHP v5.1 to 5.4.

(I have not seen a good test for v5.5 yet, apparently because it still works, but you can be sure that the tests will be published shortly after its release)

+8
source

This is a system independent question. Your mileage may vary depending on the environment in which you work. With that said, there is no definitive way to say whether it will be "faster." To test your specific environment, you will need to do code profiling and see that the runtime is about 5.4 code samples compared to 5.5 code samples.

0
source

I'm not sure, but I doubt that using the new syntax adds significant improvements. The parser can parse the new terser syntax more syntactically, but it generates the same operating codes as the previous one. Significant improvements here are barely noticeable.

On the other hand, newer versions improve internal performance, which means that both older and newer code work better on a newer engine.

0
source

All Articles