Possible Duplicate:
Commenting interpreted code and performance
Does comments affect when including files in PHP?
Let's say we have 100 class files and everytime when a page is requested, all these classes must be parsed by PHP.
Will PHP be slower if almost 1 half of the source code lines are the comments? Because usually I add a lot of comments & descriptions to code. This doesn't matter to compilers coz comments are not compiled, but PHP is interpreter, any bad thing may happen?
Commenting will not affect the script execution time in normal case. But the number of lines you write in your code affect the parser to read and buffer it considerably.
It can prevent functions from being inlined, which affects performance, though this shouldn't really happen. Show activity on this post. In some perhaps isolated circumstances, comments definitely somehow bog down the code execution.
Since comments have no impact on the runtime results, they are sometimes neglected when the source code is updated.
Yes, but it's minimal, and this can (and should) be addressed entirely by using APC or another opcode cache. As a bonus, APC will speed everything else up as well.
If your site is slow, comments are not the reason.
The only way it is slower, is that the interpreter has to read more bytes. But as for execution speed, it has no influence, because they are just ignored by the interpreter.
So basically, it does not matter if you add comments.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With