X
X
xmoonlight2014-11-14 04:56:53
PHP
xmoonlight, 2014-11-14 04:56:53

An out-of-the-box PHP performance review. Is a review needed?

Hello.
Interesting prospects in terms of speeding up code execution open up with proper programming of seemingly simple operations.
8c3593f25b8c438dbbc9015b7cfd57ba.png
Is a review of such tests necessary and would it be useful?
... if anyone else knows any similar methods - write in the answers.
(Only pure PHP without caching systems and any KPHP, etc.!)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey Lerg, 2014-11-14
@xmoonlight

It will be interesting to see, but there is no practical use. Who needs to speed up PHP, use KPHP and other similar things. Or even switch to other languages.
From such small tricks, the increase in productivity on real projects is negligible.
The fact that% is a resource-intensive operation is understandable. Like pro == vs ===. We need something more interesting.

F
FanatPHP, 2014-11-14
@FanatPHP

Not necessary and harmful.
Performance should be optimized by demand, not recipes.
There are hundreds of monkeys running around anyway, not understanding what they are doing, but always ready to share "solutions". No need to increase their baggage of meaningless "knowledge".
Moreover, if, say, the spell "SET NAMES utf8" turns out to be useful in the vast majority of cases (regardless of whether the speaker understands its meaning or not), then the proposed senseless game of spitballs with optimizashki does not make any sense at all, and will only litter the heads of the unfortunate monkeys.
Instead of a set of meaningless recipes, a programmer should understand the PRINCIPLE: in 99.999% of cases, such nonsense does not need to be optimized. In the event that it is really needed,first, profiling is done to determine the place that really needs optimization , and only then can you start fussing with optimization in units of percent of code sections that take up 0.0001% of the total script execution time.
The first example, by the way, has nothing to do with performance. This is purely common sense and a question of whether the programmer understands what he is doing. For the vast majority of users, the answer to this question is no. As a result, such "tricks" are obviously meaningless.
If the programmer understands that for a loop of 20K iterations, you don't need to do 100K - good. If he does not understand, then he has a lot of other problems, MUCH more critical than swarming in the sandbox with the optimization of meaningless code sections.

U
ugodrus, 2014-11-14
@ugodrus

In general, the topic is just right for these "macaques". But this is no longer the topic of a habr and a toaster, since the topic has already been cooked, eaten and digested hundreds of times.
Now there are a lot of phpshnikov divorced who have just started to practice and, accordingly, blurt out who knows what and who knows how. It is enough to read some questions here, and on many forums, to be convinced of this.
There are a lot more code optimization tricks on the net, and this example is really about nothing. If you really want to help newbies, don't do low-level php tricks with loops and statements. There are more than enough examples of optimization in this topic. Dig towards OOP. There are many more miracles out there. For many examples on the net it's hard to find something.
I did some experiments myself. And accordingly, he drew conclusions about what is better to use and what is absolutely impossible.
It's all relative though. You may encounter such a task that yours cannot turn into a need. Ultimately, optimization refers more to the entire application than to small pieces of it. You can optimize loops and use of operators or functions, but put together an application that will mercilessly eat memory due to leaks. And therefore, the price of such an optimization will be 0.
And for cycles in general. The maximum cycles for my practice for and foreach are up to 300, while up to 50,000.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question