Re: Speed

Paul Baker <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.html-template
Message-ID <[email protected]>
On Dec 2, 2005, at 12:09 PM, Octavian Rasnita wrote:

> Hi,
>
> I have some questions that I couldn't find an answer for:
>
> Which way of "inserting" vars in HTML::Template is the fastest?
> (or it doesn't make any difference?)
>
> *snip*

Someone can correct me if I'm wrong, but based on the usual perl speed 
generalizations, doing...

   $ht->param(foo => 1);
   $ht->param(bar => 2);
   $ht->param(baz => 3);

...will be slower than doing...

   $ht->param(foo => 1, bar => 2, baz => 3);

...because doing three method calls is more expansive than doing one 
and passing more data. But doing...

   $ht->param({ foo => 1, bar => 2, baz => 3 });

...should be even faster because it is more efficient to pass a single 
hashref in a method call than it is to pass a large list of arguments. 
I have not benchmarked these and have not looked at the under-lying 
code of the param method to be sure, but based on what I know about 
Perl and the speed of method calls and passing arguments, these are my 
assumptions.

> Is the speed of H::T affected if using the following options?

And I'm not sure about die_on_bad_params, but I do believe 
loop_context_vars and global_vars does add a performance hit because 
the engine then has to generate or handle more vars inside a loop than 
if they were turned off.


> Is there a better way of defining the $ht object than defining it for 
> every
> template needs to be parsed?

I don't have an answer for that.

-- 
Paul Baker

"The day Microsoft makes something that doesn't suck is probably the 
day they start making vacuum cleaners."
           -- Ernst Jan Plugge

GPG Key: http://homepage.mac.com/pauljbaker/public.asc



-------------------------------------------------------
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.