开发者

PHP Performance Question (readable code or not, web app)

I wondered if I should write my code clean and readable or rather small and unreadable... Or should I write it rea开发者_如何学Pythondable and then compress it afterwards when I'm publishing it on the web?

Ps. I'm building a web app, the faster, the better!

Thanks_


I think you are greatly underestimating PHP's performance if you think this will affect it.

Write clean, readable code. In fact write code as if the next guy to maintain it is a sociopath that knows where you live.

Edit In response to AESM's comment... not in any way that matters. Also you can edit your question if you want to expand on it, instead of leaving a comment.


PHP parses the code before executing. The first stage is tokenization, which throws out all comments and whitespaces, and converts all identifiers to tokens. This means neither meaningfull names, nor sensible comments and clean formatting will have any effects at runtime. In fact all speed effects you seem to expect from compression are already lost during tokenization.

If you do have "bigger" source files due to clean coding, then tokenization will effectively take longer. However this effect is barely meassurable compared to actual parsing and execution.

If you feel you want to optimize at that point, please consider using eaccelerator, which makes an actual difference.

greetz
back2dos


"Programs must be written for people to read, and only incidentally for machines to execute."


I'd say, write a clean/readable code and then eliminate the bottlenecks, if needed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜