4 ms·
For a bit of perspective, here's the same template being rendered with Underscore.js templates, under Node: https://gist.github.com/3905579 https://gist.github
by jashkenas 14y ago
For a bit of perspective, here's the same template being rendered with Underscore.js templates, under Node:
https://gist.github.com/3905579 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.
- arthurschreiber 14y agoWell, that comparison is not exactly fair, is it? 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!
- klaustopher 14y agoI agree, If you would be using Express.js or something similar I think node would give you numbers that look more like the rails stuff. 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.
- jashkenas 14y agoOk -- you got it. I've updated the gist with the same template running through Express. https://gist.github.com/3905579 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.
- amikazmi 14y agoYou can make the benchmark with Rails Metal, or with Rack. If you want to compare non-blocking IO, use with eventmachine.
- jeremyjh 14y agoYeah I'm pretty sure the rails benchmark is IO-bound. If that is the case it is surprising there is any noticeable difference at all between the three different Ruby template engines.
- balupton 14y agoRunning the same benchmark against DocPad a node.js framework, getting good speeds too (1147req/s). Benchmark: https://gist.github.com/3906050 https://gist.github.com/3906050 Worth noting the tests are being run against a local copy of - http://docpad-kitchensink.herokuapp.com/ http://docpad-kitchensink.herokuapp.com/ - which does a lot more stuff than the basic haml rendering.
- betageek 14y agoThis is not very useful "perspective" - as far as I can see this benchmark is run using "rails s" which boots up the WEBrick server - I seriously doubt you'd find anyone using that in production! Maybe it's best to leave this as a Rails apple-to-apples comparison...
- lerouxb 14y agoYou'll find people saying the same thing about express or even node in general.
- klaustopher 14y agoI said that the results come from running webrick, I want to give the other servers a try. But in my opinion the web server shouldn't have anything to do with the render speeds of the template language. That's why I'd love to eliminate it altogether
- zimbatm 14y agoOn my system (only tested with c=1) in a comparable minimalist setup, ruby does 1477.48 and node 2541.61. Not too bad but still 2 times slower. https://gist.github.com/3906254 https://gist.github.com/3906254
- arthurschreiber 14y agoI'd even say that the biggest contributor to this difference is the non-blocking nature of Node. Using e.g. EventMachine would probably close the Gap between Node and Ruby even more.