Hello.  I've been using Haml for a while now.  Our whole team loves
it, but it is very slow.  And yes, this impacts overall app
performance, I have railsbench numbers that back me up, at least for
our particular use cases.  Anyway, I've taken various approaches to
make it perform better.  One thing I noticed and exploited is that the
HamlEngine evals its precompiled templates every single time, instead
of eval'ing once to create a render method like ActionView does.

I uploaded a patch that implements the ActiveView style "create a
method" approach as:
precompiled_methods_patch.diff

No idea how to link to that in a posting, I am new to Google groups.
The main flaw in this patch is that it does not look at compile times
to see if it should recompile a function for a touched file.  This is
because I am working on a Rails project, not very concerned with using
Haml outside of Rails.  So for my particular case I put logic in
template.rb to trigger a recompile which you don't see in this
abstracted out version.  It needs to go somewhere else (I think?) for
the more general Haml-as-non-Rails-plugin case.

To demonstrate the impact this approach has, here is some output from
"rake benchmark":

Original:
---------------------------------------------------
Benchmark: Haml vs. ERb
---------------------------------------------------
            user     system      total        real
haml:   0.200000   0.010000   0.210000 (  0.201928)
erb:    0.050000   0.000000   0.050000 (  0.057552)
Haml/ERB: 3.50861

With method pre-eval:
---------------------------------------------------
Benchmark: Haml vs. ERb
---------------------------------------------------
            user     system      total        real
haml:   0.120000   0.000000   0.120000 (  0.121438)
erb:    0.060000   0.000000   0.060000 (  0.056232)
Haml/ERB: 2.15959

Thanks very much for Haml, it makes my views so pretty!

Hope this is useful,
Tom


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Haml" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/haml?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to