Will PHP be slower if we add too many comments in code files? [duplicate]

十年热恋 提交于 2019-12-01 03:17:36

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.

Sure, the parser has to do more work so it will be somewhat slower. In our project we used a PHP accelerator which did result in noticeable speed improvements. I'd recommend using an accelerator and then you can comment your code and not worry about performance.

The situation you described will not make it any slower in any significant way. The parser will see /* or // and simply skip to the next */ or newline respectively. However, if you have 50k lines of comments or something silly like that, it may slow the parser a little whilst it skips over them.

If you're looking for a way to speed things up, APC and memcached are great solutions.

i dont think so, maybe its 0.00001 slower but dont think this is the problem if your website loads slowly :P the parser will just ignore the comments :) he's smart!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!