I started using HAML about 10 months ago and really got used to it. It had some performance problems until version 1.8, but ever since performs pretty good.
Anyway, I decided to investigate if there are some options that can improve HAML performance a bit. One of them is so called 'ugly' mode, when HAML doesn't try to indent the code acording to it's nesting level. It's turned off by default, thus making a 'View Source' mode more traceable. Anyway, no one really needs it in the production, so let's play with it.
Here I use some integration tests for the Rails application performance benchmarking (influenced by this great article). Benchmarked page uses a very intensive partial rendering to represent hierarchical navigation, so it's a good candidate to play with.
oleg-desktop ~/Projects/grecipes/dev(dev) $ ruby test/integration/index_performance_test.rb Loaded suite test/integration/index_performance_test Started time: 1.020378947258 ± 0.206319272827473 memory: : allocated: 11714K total in 276027 allocations, GC calls: 2, GC time: 182 msec
With these lines added to environment.rb:
if ENV['RAILS_ENV'] == 'production' || ENV['RAILS_ENV'] == 'triage' Haml::Template::options[:ugly] = true end
oleg-desktop ~/Projects/grecipes/dev(dev) $ ruby test/integration/index_performance_test.rb Loaded suite test/integration/index_performance_test Started time: 0.923057436943054 ± 0.146305060993389 memory: : allocated: 11714K total in 276033 allocations, GC calls: 2, GC time: 227 msec
Not much but still a good result for the one-liner! Of course, the next thing to battle will be these 2 GC calls, but it's another story.