I've previously posted about my performance issues regarding TT.  At
the time, one of Matt's suggestions for improving performance was to
reduce the usage of uri_for() whenever possible.

I had some "list" pages where I'd need to display dozens of items and
link to each one of them and all my links were built using uri_for(),
e.g. [% c.uri_for("/item/view/$item.id") %].

I decided to give Matt's advice a try and changed that to something
along these lines:

 [% base_item_uri = c.uri_for('/item/view/') %]
 [% FOREACH item IN items %]
   [% base_item_uri  _  item.id %]
 [% END %]

This resulted in a ~20% speedup on these pages - which is a quite good
speedup for such a small change. So, if there's anyone else suffering
from some performance issues like myself, this might help out a little
bit.

I don't really know if the Catalyst devs can make uri_for() work
faster in a sane way (maybe some sort of caching of URI objects?) but
until then, I think I'll stick to this slightly less readable
approach.

I hope this tip can help others as it did help me.

-Nilson Santos F. Jr.

_______________________________________________
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/

Reply via email to