Re: Which is quicker, if-else statements
| From: | Jason Sheets | Date: | Wed, 19 Mar 2003 04:03:23 +0000 |
| Subject: | Re: Which is quicker, if-else statements | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-140245@lists.php.net to get a copy of this message | ||
As a note Turck mmcache does optimization and also caches the compiled
scripts into shared memory. Zend also has the Zend Optimizer and Zend
Encoder.
Turck mmcache is available at http://www.turcksoft.com/en/e_mmc.htm
The benchmarking I did with Turck mmcache showed that Turck was a little
over 15% faster than APC for my applications (over 35,000 lines with
over 25 classes). Turck comes with a nice web interface where you can
disable the cache or optimizer and also view the cached scripts.
Jason
On Tue, 2003-03-18 at 20:38, -{ Rene Brehmer }- wrote:
> On Wed, 19 Mar 2003 00:39:11 +0100, Ernest E Vogelsinger wrote about "Re:
> [PHP] Which is quicker, if-else statements" what the universal translator
> turned into this:
>
> >Noticeable? Probably not, except you're timing loops of a million or more
> >cycles... but it's clear that the second method needs more time (in terms
> >of cpu cycles) than the first one.
> >
> >In Intel speak, what would a compiler translate these code examples to?
> >
> >if (a == b) {} else {}
> > mov eax, {a}
> > cmp eax, {b}
> > jnz L01
> >; the "true" block goes here
> > jmp L02
> >L01:
> >; the "false" (else) block goes here
> >L02:
> >
> >As you can see there's two memory operations and one comparison.
>
> I'm totally lost here ... what does that mean???
>
> Reminds me of assembler, except that assembler is more like:
> 0001 jnp e002 e003 0005
> 0002 jmp e002 e003 0008
>
> And so on (not sure if that's fully correct ... haven't touched assembler
> since '92) ...
>
> Please ellaborate Ernest ...
>
> >However, PHP is _not_ a compiler, it's an interpreter. It "compiles" code
> >at runtime and has not the ability to perform exhaustive optimizations
> >which would cost far more time than can be gained within a single
> >execution. Additionally there's the time needed to parse the input stream
> >(tokenize, add to symbol table, execute token and expression parser, etc
> >etc). With interpreting languages the differences will rocket skyhigh
> >compared to compiled executables.
>
> Doesn't PHP precompile the files and shove the result into the cache? Or
> did I get that wrong ???
>
> Rene
>
> --
> Rene Brehmer
>
> This message was written on 100% recycled spam.
>
> Come see! My brand new site is now online!
> http://www.metalbunny.net
--
Jason Sheets <jsheets@php.net>