Re: Structured Code vs. Performance

From: Date: Thu, 29 Nov 2007 13:26:28 +0000
Subject: Re: Structured Code vs. Performance
References: 1 2 3 4 5 6 7 8  Groups: php.general 
Request: Send a blank email to php-general+get-265219@lists.php.net to get a copy of this message
Jochem Maas wrote:
Stut wrote:
Jochem Maas wrote:
Stut wrote:
Jo chem baas wrote:
            ^- wtf happened here? :-) it's quite funny if you know dutch :-)
Pass. Looking back it looks like it happened one of the times I replied. Didn't do it on purpose, honest! ;)
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.
okay, but I was just paraphrasing the man Rasmus, although I admit I may have misinterpreted (or misundersstood the 'why') - thought I pretty sure he has written on a number of occasions that code like the following sucks for op-code caches and should be avoided: if (foo()) {
    class Foo { }
}
Hopefully he's reading and will be able to give us a definitive answer.
here is the post that I was recalling: http://lists.nyphp.org/pipermail/talk/2006-March/017676.html I believe his third point validates what I was saying although I did make a bit of a mess with regard of my use of terminology.
Hmm, Rasmus seems to be saying that opcode caches have a way to optimise the definition of entities, and by defining them conditionally they can't make use of that. That kinda makes sense, but I'd expect the difference to be negligible unless you're talking about a file with thousands upon thousands of definitions. Anyhoo, back to the coalface. -Stut -- http://stut.net/

« previous php.general (#265219) next »