kracker (the)
|
Saturday 24 March 2007 2:32:01 am
@Matteo,
While I am impressed with your first post being so very detailed, I fear the first thought when I glanced at your first post was .... Most of this code belongs in php instead of tpl. In moving the logic (up the chain-o-command) to php (I think) you will the gain motivating performance improvements you seek. You might want to take a look at using the Wrap Operator extension which can provide a simple flexible way to write a php code which can return results inside of a template using a custom template operator. http://ezpedia.org/wiki/en/ez/wrap_operator <i>//kracker Audio Book - Noam Chomsky : Failed States Unabridged</i>
Member since: 2001.07.13 || http://ezpedia.se7enx.com/
|
Matteo Tomasini
|
Monday 26 March 2007 1:44:19 am
This is the code in the template
{def $kinds=array('Bene culturale','Luogo rupestre','Paesaggio/Attrazione naturale','Flora/Fauna')}
{def $places=fetch('content','list',hash(parent_node_id,59))}
{foreach $places as $place}
{def $content=concat('<a href=',$place.path_identification_string|ezurl(no),' ><b>',$place.object.data_map.name.data_text,'</b></a> - ',$place.creator.name,'<br />')}
{def $insertions=fetch('content','list',hash(parent_node_id,$place.node_id,
order_by,array('published',true()),class_filter_type, "include", class_filter_array, array(17)) ) }
{set $content=concat($content,'<br /><b>Tipologia:</b>',wrap_user_func('generateMarkerContent', array($kinds,2,$insertions)))}
{*then I pass the $content variable to the function addMarker of the Google Maps*}
The values passed to the 'generateMarkerContent' function represent the list of kinds, the array position of the Selection attribute 'kind' and the list of insertions associated to a place. This is the 'generateMarkerContent' function
function generateMarkerContent($list,$type,$insertions)
{
$count=array();
$allKinds=array();
foreach($insertions as $insertion) {
end($insertion->ContentObject->ContentObjectAttributes);
$curr=current($insertion->ContentObject->ContentObjectAttributes);
array_push($allKinds,$list[$curr['eng-GB'][$type]->DataText]);
}
$count=array_count_values($allKinds);
arsort($count);
$str='';
for ($i=0; $i<3; $i++)
{
$curr=each($count);
if (isset($curr['key']))
$str=$str . ' ' . $curr['key'] . '(' . $curr['value'] . ')';
}
if (count($count)>3)
$str=$str . ' ...'
return ($str);
}
?>
it returns a string containing the 3 most rated kinds
|
Matteo Tomasini
|
Monday 26 March 2007 11:13:12 pm
@Xavier Dutoit
Before the modification the template processing time was about 8 seconds, now is less than a second. During this time the CPU works at 100% (I have an AMD Athlon 64 3500+). The page has 5 places and about 20 Insertions.
Now I have inserted 9 places with about 50 Insertions and the template time is about 1.8sec, always with the CPU at 100%. I am quite worried about that, with about 100 places and 1000-1500 Insertions what will be the load page time? Have you got some more ideas to improve speed of my page? Thanks
|
Xavier Dutoit
|
Tuesday 27 March 2007 2:47:29 am
Hi, Assuming places and so on aren't going to change that often, use cache-block around them (with the right keys and update only when a new place is published, no time out). That's still as slow the first time, but much quicker the other times. Have a look at the documentation. X+
http://www.sydesy.com
|