PHP code comments parse speed
Does anyone have a solid benchmark about the speed of parsing 开发者_StackOverflow社区PHP code comments? Meaning, will excessive comments increase the time to process a PHP page?
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.
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...
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.
精彩评论