I
I
IsaevDev2016-03-12 21:55:44
PHP
IsaevDev, 2016-03-12 21:55:44

Does the amount of PHP code affect performance?

It is clear that 1000 and 1M lines of code will be interpreted at different times. But still, how critical is the amount of code in PHP 7?
Unfortunately, under load it was not necessary to observe the effect.
Do I understand correctly that OPcache was just made to cache the interpreted code?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Silm, 2016-03-13
@IsaevDev

...the question is whether it is possible to collect all the business logic in one class or should it be broken and connected as needed

The whole point of writing in PHP is to use its capabilities to create a human application architecture.
If you really really need performance and the design of the application is not important, the possibility of convenient development, easy extension, modularity, are not interested in plug-in libraries, then why do you need PHP? Choose a low-level PL, write on it. It will work super fast if you live to see the release.
Answer: In the era of OPcache, the impact of code size on performance is negligible.
Do I understand correctly that OPcache was just made to cache the interpreted code?
Yes.

Z
Zhbert, 2016-03-12
@Zhbert

You can write such a code that one line will hang everything to hell ...

A
Alexey Skobkin, 2016-03-12
@skobkin

Much more important is what this code does.
In the Symfony framework, for example, all the necessary application classes are collected in one cache file so that they can be loaded at once, and not one from a thousand files. That is, sometimes one large file is justified. However, it is better to do this automatically (as Symfony does) so as not to impair the readability and maintainability of the code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question