Question

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.

Was it helpful?

Solution

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

OTHER TIPS

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.

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.

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

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.

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.

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.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top