Y
Y
Yuri2017-01-03 20:27:58
symfony
Yuri, 2017-01-03 20:27:58

Do you clean comments in PHP code for optimization?

I suppose that many will now teach me that PHP is compiled into opcode and executed from there, and comments are ignored in the opcode.
but there is a small nuance, comments that open with / ** before class methods and properties are regarded as annotations and can be obtained through reflection, that is, they must be in the opcode.
example

<?php

class A
{
    /**
     * тут много много разного текста
     */ 
    public $a;
}

echo memory_get_usage();

If you change the text size, then the consumption of RAM changes.
if you replace /** with /* then the consumption is reduced and does not depend on the size of the comment. that is, the comment is not regarded as an annotation and is not compiled into an opcode.
PS initially I wanted to make a revision in the vendor folder in symphony, it annoys me its size of 150mb for each project, as it turned out, you can easily reduce it to 50 if you cut folders like Tests/Fictures/Docs/.git that are not needed on the production (the size of the latter for some bundles, especially touches). at least the size of the distribution will be smaller. if you cut out comments-annotations that are often not used (of course there are exceptions - annotations that are actually used), then you can also reduce the consumption of RAM, and I also think indirectly and the speed will improve.
so the question is in the title.
it may seem that saving on matches, but in symphony, annotations are often used only as php-doc but with /**. and there are dozens of megabytes of code. I was wondering how much RAM can be saved by this.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill Nesmeyanov, 2017-01-03
@SerafimArts

1) Symphony already compiles most of the kernel files in app[Env]Kernel into the app folder
2) Considering that a significant part of the application logic is built on the basis of annotations, deleting them is comparable to deleting the source code.
It will also be faster by 0.001 % and everything will break in the same way
. Such thoughts are a relic of the times of php 4, now it's easier to install php 7 than to trash the sources (which, by the way, will have to be "cleaned" every couple of weeks by hand, because kernel updates do not go anywhere).
And it's even easier to disable some bundle or rewrite one heavy sql \ dql query - it will be much more profitable in terms of speed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question