views:

159

answers:

3

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?

+1  A: 

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.

JonnyLitt
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
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
+5  A: 

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.

N 1.1
A: 

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...

Andrew Heath