I coded a site with an outer loop, an inner loop and an inner inner loop. 
global_vars and loop_context_vars were on.  
 
I was wondering about the time the output of this site lasts: 14 seconds ! 
After this I turned gobal_vars and loop_context_vars off and was wondering 
again: the output was processed after 1.5 seconds. 
 
I wrote a simplified Example (see below) and got the following results on my 
system: 
global_vars=1, loop_context_vars=1: 2.4 seconds 
global_vars=1, loop_context_vars=0: 5.7 seconds 
global_vars=0, loop_context_vars=1: 5.7 seconds 
global_vars=1, loop_context_vars=1: 13.0 seconds !!! 
 
So here is my question: Is this behavior normal ? 
 

Example: Please toggle the values of global_vars and loop_context_vars to see 
the difference. 


html_tmpl.pl--------------------------------------------- 
#!/usr/bin/perl -w 
 
use HTML::Template; 
use Time::HiRes qw(gettimeofday); 
 
my $inner_loop; 
for(my $i=0; $i<500; $i++) { 
  my $inner_inner_loop; 
  for(my $dat=1; $dat<=12; $dat++) { 
    push(@$inner_inner_loop, {'data' => $dat}); 
  } 
  push(@$inner_loop, { 'inner_inner_loop' => $inner_inner_loop }); 
} 
 
my $outer_loop; 
push(@$outer_loop, {'inner_loop' => $inner_loop}); 
 
my $tmpl = HTML::Template->new(filename=>'html_tmpl.tmpl', global_vars=>1, 
loop_context_vars=>0); 
$tmpl->param('outer_loop' => $outer_loop); 
 
my $t0 = gettimeofday; 
my $output = $tmpl->output(); 
my $t1 = gettimeofday; 
print $t1-$t0; 
------------------------------------------------------ 


html_tmpl.tmpl---------------------------------------- 
<tmpl_loop name="outer_loop"> 
  <tmpl_loop name="inner_loop"> 
    <tmpl_loop name="inner_inner_loop"> 
      <tmpl_var name="data">
    </tmpl_loop>
  </tmpl_loop> 
</tmpl_loop> 


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Html-template-users mailing list
Html-template-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/html-template-users

Reply via email to