Re: Why Should I Use Zend Optimizer?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 27 Mar 2006, at 17:36, Jonathan Duncan wrote:

I posted this on the Zend.com forums but have not been able to get a response yet. So I decided to ask the people that know.

I do not understand the need for an optimizer. What exactly is Zend Optimizer optimizing? If it is changing my code, then how about if I just learn how to code better? Is that all that Zend Optimizer is doing? Making my code better?

Think of the guts of PHP (the Zend Engine) as being like a virtual computer, complete with processor. When your PHP script is run, PHP takes it and first of all it is run through a lexer which will convert all of your wonderfully human-readale code (no matter how badly written!) into tokens suitable for this virtual CPU. The tokens are then passed over to the 'parser'. The parser takes each token and generates an instruction set. This is an assembly style form of code that runs on the Zend Engine. Finally it is executed.

It is this process that the Zend Optimiser (and packages like it) speed up. Typically they will compile your scripts into 'executables' (for want of a better phrase), so that each time your script is called none of that lexer/parsing stage has to happen. It just executes and returns.

<slight diversion>

This whole process, and the fact that the Zend Engine IS a Virtual Machine in its own right, is why I get annoyed at people who claim that you cannot speed-up your scripts by changing the way certain things happen. I remember somebody posted a comment to my blog once to the effect of 'you aren't coding in assembly, it makes no difference what you do!' - which is of course complete crap, because actually your code does have a very direct correlation to the efficiency of the intermediate code that is generated and executed.

</slight diversion>

In short, Zend Optimise has *nothing* at all to do with 'making dumb programmers code better' I'm afraid.

Cheers,

Rich
--
http://www.corephp.co.uk
Zend Certified Engineer
PHP Development Services

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux