Forums / Setup & design / Request for Efficiency Suggestions

Request for Efficiency Suggestions

Author Message

Alex Jones

Monday 01 December 2003 7:20:46 am

I am displaying a chart listing the elements in several types of steel. The chart takes quite a while to load when hit for the first time (about 2 minutes) on a pretty solid server, so I am seeking any ideas that can rectify the situation.

The page is built by looping through two folders which in turn hold each individual steel (a custom class). The information is displayed within a table, each field within its own TD. If a field is empty an emdash (—) is inserted. To see what this looks like, you can view a static version of the page at http://www.agrussell.com/knife_information/steel_guide/ One more note, I am using the glossary operator on some of the fields as well.

The class has 11 fields in addition to the Name, Identifier and Object Name Pattern. Ten of the fields are Text Lines, the other is an XML Text Field. I already have a lot of information stored, so I cannot start with a new class or eliminate any of the fields.

Ideally someone can point out some weak practices in my code (below) that, once repaired, will make a difference.

[Code]------------------------------
{let top_cat=842 used_node=false()} {* Set the top node *}
{set used_node=$top_cat}
{let node_obj=fetch(content,node,hash(node_id,$used_node))} {* Get a proper node object *}
{section loop=fetch(content,list,hash(parent_node_id,$top_cat, class_filter_type, "include", class_filter_array, array(1),sort_by,array("priority", true())))}
<table border="0" cellpadding="0" cellspacing="0" width="730">
<tr class="TableName">
<th colspan="3">{$:item.name}</th>
<td colspan="6"> </td>
</tr>
<tr class="TableHead">
<th width="100">Steel</th>
<th width="80">{"Carbon"|glossary(true,472,"replace")}<br />(C)</th>
<th width="80">{"Manganese"|glossary(true,472,"replace")}<br />(Mn)</th>
<th width="80">{"Chromium"|glossary(true,472,"replace")}<br />(Cr)</th>
<th width="70">{"Nickel"|glossary(true,472,"replace")}<br />(Ni)</th>
<th width="80">{"Vanadium"|glossary(true,472,"replace")}<br />(V)</th>
<th width="80">{"Molybdenum"|glossary(true,472,"replace")}<br />(Mo)</th>
<th width="80">{"Tungsten"|glossary(true,472,"replace")}<br />(W)</th>
<th width="70">{"Cobalt"|glossary(true,472,"replace")}<br />(Co)</th>
<th width="65">{"Typical Hardness"|glossary(true,472,"replace")}</th>
</tr>
{sequence name=Seq loop=array(Row2,Row1)}
{section loop=fetch(content,list,hash(parent_node_id,$:item.node_id, sort_by,array("priority", true())))}
<tr class="{$Seq:item}">
<td class="Grade">{$:item.name|glossary(true,472,"replace")}</td>
<td>{section show=eq($:item.data_map.carbon.content,'')}&mdash;{section-else}{$:item.data_map.carbon.content}{/section}</td>
<td>{section show=eq($:item.data_map.manganese.content,'')}&mdash;{section-else}{$:item.data_map.manganese.content}{/section}</td>
<td>{section show=eq($:item.data_map.chromium.content,'')}&mdash;{section-else}{$:item.data_map.chromium.content}{/section}</td>
<td>{section show=eq($:item.data_map.nickel.content,'')}&mdash;{section-else}{$:item.data_map.nickel.content}{/section}</td>
<td>{section show=eq($:item.data_map.vanadium.content,'')}&mdash;{section-else}{$:item.data_map.vanadium.content}{/section}</td>
<td>{section show=eq($:item.data_map.molybdenum.content,'')}&mdash;{section-else}{$:item.data_map.molybdenum.content}{/section}</td>
<td>{section show=eq($:item.data_map.tungsten.content,'')}&mdash;{section-else}{$:item.data_map.tungsten.content}{/section}</td>
<td>{section show=eq($:item.data_map.cobalt.content,'')}&mdash;{section-else}{$:item.data_map.cobalt.content}{/section}</td>
<td>{section show=eq($:item.data_map.hrc.content,'')}&mdash;{section-else}{$:item.data_map.hrc.content}{/section}</td>
</tr>
{* Next sequence *}
{sequence name=Seq}
{/section}
<tr class="TableHead">
<th width="100">Steel</th>
<th width="80">{"Carbon"|glossary(true,472,"replace")}<br />(C)</th>
<th width="80">{"Manganese"|glossary(true,472,"replace")}<br />(Mn)</th>
<th width="80">{"Chromium"|glossary(true,472,"replace")}<br />(Cr)</th>
<th width="70">{"Nickel"|glossary(true,472,"replace")}<br />(Ni)</th>
<th width="80">{"Vanadium"|glossary(true,472,"replace")}<br />(V)</th>
<th width="80">{"Molybdenum"|glossary(true,472,"replace")}<br />(Mo)</th>
<th width="80">{"Tungsten"|glossary(true,472,"replace")}<br />(W)</th>
<th width="70">{"Cobalt"|glossary(true,472,"replace")}<br />(Co)</th>
<th width="65">{"Typical Hardness"|glossary(true,472,"replace")}</th>
</tr>
</table>
{/section}
{/let}
{/let}
[/Code]------------------------------

Any help is greatly appreciated!

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Bruce Morrison

Monday 01 December 2003 2:31:41 pm

Hi Alex

One thing that would help is to move the generation of the table headings to a variable using a {set-block}

e.g.
{set-block variable=tableHead}
<tr class="TableHead">
<th width="100">Steel</th>
<th width="80">{"Carbon"|glossary(true,472,"replace")}<br />(C)</th>
<th width="80">{"Manganese"|glossary(true,472,"replace")}<br />(Mn)</th>
<th width="80">{"Chromium"|glossary(true,472,"replace")}<br />(Cr)</th>
<th width="70">{"Nickel"|glossary(true,472,"replace")}<br />(Ni)</th>
<th width="80">{"Vanadium"|glossary(true,472,"replace")}<br />(V)</th>
<th width="80">{"Molybdenum"|glossary(true,472,"replace")}<br />(Mo)</th>
<th width="80">{"Tungsten"|glossary(true,472,"replace")}<br />(W)</th>
<th width="70">{"Cobalt"|glossary(true,472,"replace")}<br />(Co)</th>
<th width="65">{"Typical Hardness"|glossary(true,472,"replace")}</th>
</tr>
{/set-block}

place this at the top of the template and replace each existing table heading with {$tableHead}

This way all those calls to the glossary operator only happen once instead of twice for each outer loop.

Turn on debugging and have a look at the timing values at the end of the output. You should be able to see where any issues are.

Hope this helps

Cheers
Bruce
http://www.designit.com.au

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Alex Jones

Monday 01 December 2003 2:49:28 pm

Thanks Bruce!

I had actually (re)discovered set-block earlier this afternoon for another area that I am trying to improve, but it hadn't even occured to me to use it there. That is very helpful indeed. :)

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>