문제

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.

도움이 되었습니까?

해결책

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

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top