HAML vs ERB vs SLIM in terms of render speed
github.com
github.com
https://gist.github.com/3905579
Whereas the original Ruby templates in the original benchmarking do about 40-50 requests per second, with "c=1", the JavaScript templates do 1,732 requests per second on my laptop.
With "c=10", they do 2,370 requests per second.
While the rails benchmark tries to compare different template engines in the same language, framework, and with blocking IO, you're comparing these results to rendering under "pure" Node.js (no framework that slows you down) with non-blocking IO.
Don't take this the wrong way, tho, I'm absolutely blown away by your numbers!
But I'm really interested in eliminating as much of the framework as possible to get more comparable numbers even to other platforms.
I'm also sort of blown away by the throughput node allows you.
https://gist.github.com/3905579
Take note that the margin of variance on these numbers is several hundred, so don't read too much into small shifts ... but:
With Express, and "c=1", I get 1,876 requests per second.
With Express, and "c=10", I get 2,730 requests per second.
There isn't meaningful overhead imposed by Express for this particular simple template rendering.
Worth noting the tests are being run against a local copy of - http://docpad-kitchensink.herokuapp.com/ - which does a lot more stuff than the basic haml rendering.
Are you running the server in production mode?
Slim already has a set of benchmarks that compares it to Haml and ERB in various settings: https://github.com/stonean/slim#benchmarks
Do all three template engines use automatic HTML escaping?
Haml uses pretty-mode in development and ugly-mode in production.
But I just went with the out-of-the-box config, as do most Haml projects I've come across
ERB: 9.619 seconds
Haml: 10.893 seconds
Slim: 10.195 seconds
Full details at https://gist.github.com/3906297
Because the test is done on top of webrick, the document size probably matters more than we think. You could also give a baseline by returning a raw string to show the framework overhead.
But I think if I do the comparison without a full web stack, people will be like "Yeah, in this lab scenario ... But the real world looks different because of this and that in rails"
Are there any downsides to Slim that I should be aware of?
Sources: https://github.com/stonean/slim#slim, https://github.com/haml/haml/issues/436