Git Product home page Git Product logo

hamlerbslim's Introduction

HAML vs ERB vs SLIM

It has been going around, that HAML is performing badly when compared to other template languages in the Ruby/Rails world. For Cologne.rb, Lucas and I were preparing a talk about HAMLvsERB. So I wanted to investigate the differences in render time and possible requests per second.

Here are my results ๐Ÿ˜„

This is a simple Rails App that uses one of the Twitter Bootstrap Samples with just a little bit of Ruby Code to demonstrate the differences in parsing speeds between the three template languages

If you find anything that doesn't add up or you want to investigate any of the open questions, please discuss this on Hackernews or send me an Issue or Pull Request

How to setup?

git clone https://github.com/klaustopher/hamlerbslim.git
cd hamlerbslim
bundle
rails server >/dev/null 2>/dev/null

To get the numbers, use AB (Apache Benchmark)

ab -n 1000 -c 1 http://localhost:3000/erb
ab -n 1000 -c 1 http://localhost:3000/haml
ab -n 1000 -c 1 http://localhost:3000/slim

What I want to test in the future

  • Does the amount of partials make a difference (because the parser is invoked multiple times)? ==> Do patterns like SMACCS/SMURF have a huge negative impact on render time?
  • Do other servers (like Puma, Unicorn, Thin, etc) make a difference?
  • Is it reproducable on other stacks like Sinatra?

Results I got

Here are my results, I ran them a few times, with and without restarting the server in between, it didn't really make a difference

ERB

Document Path:          /erb
Document Length:        7590 bytes

Concurrency Level:      1
Time taken for tests:   20.929 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      7964000 bytes
HTML transferred:       7590000 bytes
Requests per second:    47.78 [#/sec] (mean)
Time per request:       20.929 [ms] (mean)
Time per request:       20.929 [ms] (mean, across all concurrent requests)
Transfer rate:          371.61 [Kbytes/sec] received

HAML

Document Path:          /haml
Document Length:        10095 bytes

Concurrency Level:      1
Time taken for tests:   26.036 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      10470000 bytes
HTML transferred:       10095000 bytes
Requests per second:    38.41 [#/sec] (mean)
Time per request:       26.036 [ms] (mean)
Time per request:       26.036 [ms] (mean, across all concurrent requests)
Transfer rate:          392.71 [Kbytes/sec] received

SLIM

Document Path:          /slim
Document Length:        6086 bytes

Concurrency Level:      1
Time taken for tests:   20.902 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      6460000 bytes
HTML transferred:       6086000 bytes
Requests per second:    47.84 [#/sec] (mean)
Time per request:       20.902 [ms] (mean)
Time per request:       20.902 [ms] (mean, across all concurrent requests)
Transfer rate:          301.82 [Kbytes/sec] received

hamlerbslim's People

Contributors

klaustopher avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.