Re: Structured Code vs. Performance

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

 



Jo chem baas wrote:
Stut wrote:
Jochem Maas wrote:
news_yodpeirs@xxxxxxxxxxxx wrote:
I got different portions of code only used for certain purposes (who
don't ;-)?). But what, in your opinion (better: in your experience)
would be the best regarding script-performance: Putting each
code-portion in a separate file and include it if required, putting
it in a constant-dependent if-structure (if (defined('FOO') && FOO)
{class foo{}; function foo(); ...})
defining functions or classes conditionally is not recommended,
because it
means they can only be defined at runtime and not compile time ...
which will
kill any op-code caching you might have in place or use in future
(e.g. php.net/apc)
I'm not completely sure, but I think you're wrong there. Removing the
condition in the example above will not affect any opcode caching since
PHP cannot determine the result of that conditional until runtime.

one of us is reading the other's post incorrectly - I have a feeling we are
both trying to say the same thing.

namely runtime class definitions don't have the same benefit of op-code caching
as compiletime definitions.

or not?

Not ;). There is no such thing as a compile-time definition in PHP.

Whether there is conditional definition or not, the opcode cache will look the same. The reason for this is that function and class definitions happen at runtime not compile time. This would have to be the case for conditional definition to work at all, since the compiler cannot determine the value of a condition at compile-time.

-Stut

--
http://stut.net/

--
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