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>

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 19 2025 04:14:25
Script start
Timing: Jan 19 2025 04:14:25
Module start 'layout'
Timing: Jan 19 2025 04:14:25
Module start 'content'
Timing: Jan 19 2025 04:14:27
Module end 'content'
Timing: Jan 19 2025 04:14:27
Script end

Main resources:

Total runtime1.4881 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0063 590.3906152.6250
Module start 'layout' 0.00630.0036 743.015639.4453
Module start 'content' 0.00991.4768 782.4609570.2734
Module end 'content' 1.48670.0014 1,352.734420.4688
Script end 1.4880  1,373.2031 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.2123160.0002
Check MTime0.00130.0875160.0001
Mysql Total
Database connection0.00060.042310.0006
Mysqli_queries1.421895.5496570.0249
Looping result0.00070.0451550.0000
Template Total1.454297.720.7271
Template load0.00180.117720.0009
Template processing1.452497.604620.7262
Template load and register function0.00010.005710.0001
states
state_id_array0.00140.092310.0014
state_identifier_array0.00300.199320.0015
Override
Cache load0.00160.1103970.0000
Sytem overhead
Fetch class attribute can translate value0.00050.032320.0002
Fetch class attribute name0.00110.071450.0002
XML
Image XML parsing0.00090.057920.0004
class_abstraction
Instantiating content class attribute0.00000.000560.0000
General
dbfile0.00180.1181220.0001
String conversion0.00000.000740.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 17
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs