Snog
Well-known member
I just spent a good portion of a day going through add-ons that are being run on a low power server to see if I could speed things up a bit.
What I found was almost scary.
I found a good portion of the add-ons using code something like this in their listeners...
The way that's coded and entered into the listeners, that code runs on every single page load.
That really isn't bad if the only add-on running on the server is that one. But, when you multiply that by 30 to 40 add-ons it really starts accumulating.
If there were separate listeners for each one with the event hint filled in, they would only run when needed.
I was able to trim almost a full point off the server load by putting event hints in a good portion of the add-ons. But I wasn't able to hit them all.
Now I'm just as guilty as the next guy and sometimes I fail to use the event hint. But, I think we should all be thinking of them when we code.
What I found was almost scary.
I found a good portion of the add-ons using code something like this in their listeners...
Code:
public static function loadClassModel($class, array &$extend)
{
if ($class == 'XenForo_Model_Conversation')
{
$extend[] = 'XXXX_Model_Conversation';
}
else if ($class == 'XenForo_Model_Like')
{
$extend[] = 'XXXX_Model_Like';
}
else if ($class == 'XenForo_Model_AddOn')
{
$extend[] = 'XXXX_Model_AddOn';
}
}
The way that's coded and entered into the listeners, that code runs on every single page load.
That really isn't bad if the only add-on running on the server is that one. But, when you multiply that by 30 to 40 add-ons it really starts accumulating.
If there were separate listeners for each one with the event hint filled in, they would only run when needed.
I was able to trim almost a full point off the server load by putting event hints in a good portion of the add-ons. But I wasn't able to hit them all.
Now I'm just as guilty as the next guy and sometimes I fail to use the event hint. But, I think we should all be thinking of them when we code.