Does anyone have a solid benchmark about the speed of parsing PHP code comments? Meaning, will excessive comments increase the time to process a PHP page?
-
Possible duplicate of [Commenting interpreted code and performance](http://stackoverflow.com/questions/7730948/commenting-interpreted-code-and-performance) – Paul Roub Apr 24 '17 at 18:00
4 Answers
Useless optimization
b. strip off comments to speed up code
Not a solid benchmark, but this particular post has great PHP performance tips and some mythbusters.
Comments are not parsed in PHP but rather ignored and PHP skips over them, in excess they only add to your diskspace. Otherwise, comments do not lag down processing at all.

- 763
- 6
- 11
-
My guess is that the OP knew this. He is probably interested in what time it takes for the parser to determine 'what to skip' – Jacco Mar 17 '10 at 00:14
-
Ah, in that case I would guess it's far below a fraction of a millisecond. PHP "compiles" on the fly which means overhead he would have the same load-time with the added comments. – JonnyLitt Mar 17 '10 at 00:18
I could see someone wanting to strip comments to reduce the filesize when downloading the PHP page to the user, but you'd have to really have comment diarrhea to make that worthwhile, and if you have comment diarrhea your code is probably too hard to read on its own and stripping all the comments would screw the next person to look at it, so...

- 6,208
- 10
- 45
- 68
This user made a very thorough attempt to answer this question.
https://stackoverflow.com/a/42166652/3774582
The conclusion is that the difference is so negligible, that he was unable to find a measurable difference.