Do php comments take server time?

2019-07-04 19:33发布

问题:

I am working on speeding up the response time of the website I'm currently working on. Can anyone tell me if the php parser takes the time to look at the code within comment blocks, or is it completely ignored? I ask because I'm wondering if removing many large blocks of commented code would do anything to improve page rendering time. Thanks.

回答1:

They're ignored. The PHP tokenizer essentially jumps right over them.



回答2:

parse rules for "jumping" over comments are well established and extremely low-overhead. removing comments will save a miniscule sliver of processing time, but you will never notice it.

and the time consumed trying to read code without comments will be a far greater penalty down the road.



回答3:

accelerator (eaccelerator, xcache, apc or simialar) will make a big difference on big php-files.

It may be a db-related issue though. (indexes??)

Keep your comments, you will forget or someone will take over.



回答4:

If you want to improve PHP performance, install bytecode cache (such as apc). That would make PHP not to recompile files every time



回答5:

You might be able to ditch a single $2,000 server if you had Facebook's 500,000,000 users. For most sites, though, you've wasted more billable time considering the issue than you'll realize in a century's worth of cost savings.



回答6:

if you use APC(you really SHOULD) the bytecode is stored in memory(big win) so you don't even have to think about it. Although I assume the penalty is subpar.



回答7:

The parser has to see it; that's how it knows where the comment begins and ends. It's not put into the bytecode though, so it's only seen once per process.



回答8:

Search Php hip hop. Facebook uses it to compile Php to native code. Its very fast.