My team started using HAML recently, we have tons of erb views still,
but we're doing all new ones in HAML.

However, we recently noticed a performance issue in our views (erb
ones), debugging the problem led us to the capture method, which in
turn pointed fingures to HAML.
To my surprise (I am the HAML fanboy in the team), disabling HAML made
erb templates load twice as fast. I am strictly referencing views that
use the capture method (i.e., content_tag).

To make sure HAML is slowing down erb templates that use capture, I
isolated the case

Here's exactly what I did:
$ gem -v
1.8.4
$ rvm -v
rvm 1.6.16

$ rvm gemset create hamltest
$ rvm use ruby-1.9.2-p180@hamltest
$ gem install bundler (Using 1.0.14)
$ gem install rails (Using 3.0.7)
$ rails new haml_test
$ cd haml_test
$ bundle
$ rails g scaffold User name:string
$ rake db:migrate

Made 1 trivial test to hit the index view temaplte a 1000 times

  test "index" do
    1000.times { get :index }
  end

$ time rake test:functionals
real 0m6.474s
user 0m6.000s
sys 0m0.410s

(Adding HAML) $ echo "gem 'haml'" >> Gemfile && bundle

$ time rake test:functionals
real 0m6.841s
user 0m6.300s
sys 0m0.470s

All good so far.

Next, I added this to users/index.html.erb:
<% 42.times do %><%= content_tag :div do %>TEST<% end %><% end %>

Note, content_tag uses capture

Running the test again:

(with HAML included in Gemfile) $ time rake test:functionals
real 0m12.093s
user 0m11.620s
sys 0m0.390s

(HAML not in Gemfile) $ time rake test:functionals
real 0m6.866s
user 0m6.340s
sys 0m0.460s

I tried the same test on another machine to rule out hardward/other
dependencies.

Please advice.

Thanks.
~ Samer

-- 
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