8

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

4 Answers 4

8

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

2 Comments

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

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

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.