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>

eZ debug

Timing: Jan 19 2025 04:28:54
Script start
Timing: Jan 19 2025 04:28:54
Module start 'content'
Timing: Jan 19 2025 04:28:54
Module end 'content'
Timing: Jan 19 2025 04:28:54
Script end

Main resources:

Total runtime0.7878 sec
Peak memory usage4,096.0000 KB
Database Queries194

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0062 590.1094180.8281
Module start 'content' 0.00620.6185 770.9375575.3516
Module end 'content' 0.62470.1630 1,346.2891341.0859
Script end 0.7877  1,687.3750 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00390.4972210.0002
Check MTime0.00150.1878210.0001
Mysql Total
Database connection0.00070.088710.0007
Mysqli_queries0.694688.17081940.0036
Looping result0.00220.27621920.0000
Template Total0.761396.620.3807
Template load0.00190.241920.0010
Template processing0.759496.403020.3797
Template load and register function0.00010.015610.0001
states
state_id_array0.00090.110410.0009
state_identifier_array0.00110.144520.0006
Override
Cache load0.00170.2160970.0000
Sytem overhead
Fetch class attribute can translate value0.00180.227230.0006
Fetch class attribute name0.00170.221450.0003
XML
Image XML parsing0.00150.189930.0005
class_abstraction
Instantiating content class attribute0.00000.001560.0000
General
dbfile0.00430.5441330.0001
String conversion0.00000.000630.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 17
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs