On 11/25/07, aaron@svn.wikimedia.org aaron@svn.wikimedia.org wrote:
/**
* As we use the same small set of messages in various methods and that
* they are called often, we call them once and save them in $this->message
*/
function preCacheMessages() {
// Precache various messages
if( !isset( $this->message ) ) {
$this->message['last'] = wfMsgExt( 'last', array( 'escape') );
}
}
As a general remark (I've seen this technique in more than one special page's code), do we really need this? Doesn't MessageCache handle local message caching anyway?
Simetrical wrote:
On 11/25/07, aaron@svn.wikimedia.org aaron@svn.wikimedia.org wrote:
/**
* As we use the same small set of messages in various methods and that
* they are called often, we call them once and save them in $this->message
*/
function preCacheMessages() {
// Precache various messages
if( !isset( $this->message ) ) {
$this->message['last'] = wfMsgExt( 'last', array( 'escape') );
}
}
As a general remark (I've seen this technique in more than one special page's code), do we really need this? Doesn't MessageCache handle local message caching anyway?
wfMsg() profiles at ~200us, so it would save a little bit of time if you're going to be using the message lots of times. I've usually found local variables to be sufficient as a temporary cache, maybe there's some special reason in this case why it needs to be in the object.
-- Tim Starling
On 11/25/07, Tim Starling tstarling@wikimedia.org wrote:
wfMsg() profiles at ~200us
You're right, it seems to take quite a while (100-200 μs) even if it doesn't have to go to memcached or the database, at least here on localhost. Doesn't seem to decrease much with successive executions either. The practice trades a couple kilobytes of memory for a few milliseconds' execution time, I guess. Probably not a bad idea, but local variables are good enough for me.
wikitech-l@lists.wikimedia.org