[Catalyst] Performance

Christopher H. Laco claco at chrislaco.com
Fri Mar 9 12:20:53 GMT 2007


Nilson Santos Figueiredo Junior wrote:
> On 3/8/07, Jim Spath <jspath at pangeamedia.com> wrote:
>> URI is next up at around 14% of time.  Is there anything that can be
>> done about this one?
> =

> Wherever is reasonably possible, instead of actually using calls to
> $c->uri_for() for every item, call it only once and then build the
> rest of the URI manually.
> =

> This is specially useful on those tables where each line links to a
> different item. Then, instead of something like:
> =

>  [% FOREACH item IN items %]
>    [% c.uri_for('/item', item.id) %]
>  [% END %]
> =

> Use something like:
> =

>  [% base_uri =3D c.uri_for('/item') %]
>  [% FOREACH item IN items %]
>    [% base_uri %]/[% item.id %]
>  [% END %]
> =

> By making this kind of changes throughout an entire Catalyst
> application I've been able to get 15-20% better performance.
> =

> -Nilson Santos F. Jr.
> =

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

> =


Even better, just don't use uri_for if you don't have to. Relative uris
are your friend. They still work. The web still functions without
uri_for. :-)

If you are working on an index page, and you have create/edit/view links
that are relative to that page, just use html:

##default
[% FOREACH item in items %]
   <a href=3D"[% item.id %]">...</a>
[% END %]

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
Url : http://lists.scsys.co.uk/pipermail/catalyst/attachments/20070309/44ac=
ebea/signature.pgp


More information about the Catalyst mailing list