16 seconds?   I'm with Byron on this.  Something is wrong, and it's
not with your template or Velocity's parsing.  This template is
neither long enough nor complicated enough to get anywhere close to
that time for parsing on any sort of modern system.  What system is
this on?  Are you using a custom resource loader?  URLResourceLoader
over a slow connection?  What profiler are you getting the 16000ms
time from?  It would be best to know exactly where in your system this
time is being spent.

On Mon, Dec 29, 2008 at 1:11 AM, bluejoe <[email protected]> wrote:
> Hi, all. My template file is shown below, getTemplate() cost more than 
> 16000ms to load it. I don't know what's wrong with it. This template is 
> created automatically by another Velocity client class (I named it as 
> TemplatePublisher), so it is too ugly and long. Who can tell me how to 
> optimize this template to make the loading time shorter?
>
> thanks a lot!
>
> ============== my poor template ==============
>
> <!--created by VdbPublisher at 2008-12-27 00:14:31-->
> #if ($pageViewer.beans.size() == 0)
> <center>
>  <div style="width:100%" align="left"> <br>
>    <p><font color="#cccccc">no records...</font></p>
>  </div>
> </center>
> #else
> <table align="center" width="100%" border="1" cellpadding="6" class="table1 
> dataset book">
>  <tr class="header">
>       <td align="center" fieldId="8a8080841c833108011c8331087c0002" 
> orderAsc="${jsoQuery.orderAsc}"  onclick="setOrderBy(this)" 
> style="cursor:hand" title="order by number" ><b><img src="/images/key.gif" 
> align="absbottom"> number</b>#if ('8a8080841c833108011c8331087c0002' == 
> $jsoQuery.orderId)<img src="/images/${jsoQuery.orderAsc}.gif" 
> align="absbottom" width="13">#end</td>
>          <td align="center" fieldId="8a8080841c833108011c8331087c0003" 
> orderAsc="${jsoQuery.orderAsc}"  onclick="setOrderBy(this)" 
> style="cursor:hand" title="order by title" ><b> title</b>#if 
> ('8a8080841c833108011c8331087c0003' == $jsoQuery.orderId)<img 
> src="/images/${jsoQuery.orderAsc}.gif" align="absbottom" width="13">#end</td>
>          <td align="center" fieldId="1f62836e1c8dd5da011c8dd909b00001" 
> orderAsc="${jsoQuery.orderAsc}"  onclick="setOrderBy(this)" 
> style="cursor:hand" title="order by price" ><b> price</b>#if 
> ('1f62836e1c8dd5da011c8dd909b00001' == $jsoQuery.orderId)<img 
> src="/images/${jsoQuery.orderAsc}.gif" align="absbottom" width="13">#end</td>
>          <td align="center" fieldId="1f62836e1c8dd5da011c8dd925d30003" 
> orderAsc="${jsoQuery.orderAsc}"  onclick="setOrderBy(this)" 
> style="cursor:hand" title="order by modification time" ><b> modification 
> time</b>#if ('1f62836e1c8dd5da011c8dd925d30003' == $jsoQuery.orderId)<img 
> src="/images/${jsoQuery.orderAsc}.gif" align="absbottom" width="13">#end</td>
>          <td align="center" fieldId="1f62836e1c8de132011c8e09666d0001" 
> orderAsc="${jsoQuery.orderAsc}"  onclick="setOrderBy(this)" 
> style="cursor:hand" title="order by description" ><b> description</b>#if 
> ('1f62836e1c8de132011c8e09666d0001' == $jsoQuery.orderId)<img 
> src="/images/${jsoQuery.orderAsc}.gif" align="absbottom" width="13">#end</td>
>          <td align="center" fieldId="1f62836e1c8de132011c8e0984550003" 
> orderAsc="${jsoQuery.orderAsc}"  style="color:#888888" title="unsortable" 
> ><b> images</b>#if ('1f62836e1c8de132011c8e0984550003' == 
> $jsoQuery.orderId)<img src="/images/${jsoQuery.orderAsc}.gif" 
> align="absbottom" width="13">#end</td>
>          <td align="center" fieldId="1f62836e1c8de132011c8e09b4000005" 
> orderAsc="${jsoQuery.orderAsc}"  onclick="setOrderBy(this)" 
> style="cursor:hand" title="order by publish date" ><b> publish date</b>#if 
> ('1f62836e1c8de132011c8e09b4000005' == $jsoQuery.orderId)<img 
> src="/images/${jsoQuery.orderAsc}.gif" align="absbottom" width="13">#end</td>
>          <td align="center" fieldId="ff8080811db4d587011db4e3fab5000a" 
> orderAsc="${jsoQuery.orderAsc}"  onclick="setOrderBy(this)" 
> style="cursor:hand" title="order by isNew" ><b> isNew</b>#if 
> ('ff8080811db4d587011db4e3fab5000a' == $jsoQuery.orderId)<img 
> src="/images/${jsoQuery.orderAsc}.gif" align="absbottom" width="13">#end</td>
>          <td align="center" fieldId="ff8080811db4d587011db4e811f3000d" 
> orderAsc="${jsoQuery.orderAsc}"  style="color:#888888" title="unsortable" 
> ><b> vfield</b>#if ('ff8080811db4d587011db4e811f3000d' == 
> $jsoQuery.orderId)<img src="/images/${jsoQuery.orderAsc}.gif" 
> align="absbottom" width="13">#end</td>
>          <td align="center" fieldId="ff8080811db4ec19011db4ec61c50001" 
> orderAsc="${jsoQuery.orderAsc}"  style="color:#888888" title="unsortable" 
> ><b> location</b>#if ('ff8080811db4ec19011db4ec61c50001' == 
> $jsoQuery.orderId)<img src="/images/${jsoQuery.orderAsc}.gif" 
> align="absbottom" width="13">#end</td>
>          <td align="center" fieldId="ff8080811e5245cc011e524aaa1a0005" 
> orderAsc="${jsoQuery.orderAsc}"  style="color:#888888" title="unsortable" 
> ><b> authors</b>#if ('ff8080811e5245cc011e524aaa1a0005' == 
> $jsoQuery.orderId)<img src="/images/${jsoQuery.orderAsc}.gif" 
> align="absbottom" width="13">#end</td>
>        <td class="header"></td>
>  </tr>
>  #foreach ($bean in $pageViewer.beans)
>  #set ($id = $bean.id.jdbcObject)
>  #set ($flag = $velocityCount%2)
>    <tr id="DATAGRID_ROW" class="bg${flag}" checked="false" 
> originalClass="bg$flag" rowID="${id}" onmouseout="hiliteRecord(this, false)" 
> style="cursor:hand" onclick="toggleRecord(this);" title="click here to select 
> this row">
>        <td>$bean.id.format('%d')</td>
>        <td>$bean.title.format('%s')
> </td>
>        <td>$bean.price.format('%.2f')</td>
>        <td>$bean.posttime.dateFormat('')</td>
>        <td>$bean.desc.format('%s')
> </td>
>        <td>#foreach ($file in $bean.photo.files)
>  <a href="${file.filePath}">${file.title}[${file.fileSize}]</a><br>
> #end</td>
>        <td>$bean.publishdate.dateFormat('')</td>
>        <td>$bean.ispop.format('%s')
> </td>
>        <td>$bean.vfield.value</td>
>        <td>$bean.location.lon, $bean.location.lat</td>
>        <td><div id="13" class="DataTableView"></div>
> <script>
>  var jsoQuery_13 = new SlaveQuery('cn.csdb.paperdb.author', 
> '${bean.id.jdbcObject}', 'cn.csdb.paperdb.book.authors');
>  jsoQuery_13.pageSize = 20;
>  var jsoDataTableView_13 = new DataTableView('cn.csdb.paperdb.author', 
> jsoQuery_13, $('#13.DataTableView')[0]);
>  jsoDataTableView_13.refresh();
> </script></td>
>        <td align="center" valign="top" class="bg2"><span 
> id="TITLE_$velocityCount" style="display:none">$bean.title.format('%s')
> </span>
>  #if($!authenticator)
>  <a href=# onclick="updateRecord('8a8080841c833108011c8331087c000a', 
> '${id}');">update</a> <a href=# 
> onclick="deleteRecord('8a8080841c833108011c8331087c000a', 
> '${id}');">delete</a>
>  #end
>      </td>
>  </tr>
>  #end
> </table>
>  <p> <input type="checkbox" onclick="checkRecords(this);">select all
>  &nbsp;
>  #if($!authenticator)
>  <button onclick='deleteRecords();'><img src='/images/submit_n.gif' border=0 
> align=absbottom>delete all</button>
>  #end
>  </p>
>  #if ($pageViewer.pageCount > 1)
> <br>
> <center>
>    <div style="width:100%">
>      <div align="right">${pageViewer.footerBar1}</div>
>    </div>
>    <div style="width:100%">
>      <div align="right">${pageViewer.footerBar2}</div>
>    </div>
> </center>
>  #end
> #end

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to