GithubHelp home page GithubHelp logo

jontebol / haml-vs-hamlit-bench Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 15 KB

A small repos to benchmark various haml/hamlit/slim versions.

License: MIT License

Ruby 71.22% HTML 12.28% Haml 8.32% Slim 8.19%

haml-vs-hamlit-bench's Introduction

This was created in order to benchmark some templates with more classes (like with typical Tailwind use), to see which templating gem would be faster for our app.

Here are the results for me locally. Note that I've made changes to the benchmark script (+ templates) which may skew the results, so take this with a big grain of salt until verified by someone who knows these gems better.

UPDATE: I'm happy to report that with some changes to the benchmarks script that made the comparison accurate (haml v5.2.0 wasn't escaping html while the other gems were), and a quick little fix from @k0kubun, hamlit is now coming out on top as expected.

$ bundle exec ruby -v benchmark/slim/run-benchmarks.rb
ruby 2.6.8p205 (2021-07-07 revision 67951) [arm64-darwin21]
Calculating -------------------------------------
       erubi v1.11.0    29.191k i/100ms
         slim v4.1.0    35.388k i/100ms
       hamlit v3.0.2    36.976k i/100ms
         haml v5.2.0    29.621k i/100ms
-------------------------------------------------
       erubi v1.11.0    310.588k (± 0.6%) i/s -      1.576M
         slim v4.1.0    383.155k (± 0.4%) i/s -      1.946M
       hamlit v3.0.2    401.604k (± 1.0%) i/s -      2.034M
         haml v5.2.0    312.471k (± 1.7%) i/s -      1.570M

Comparison:
       hamlit v3.0.2:   401604.5 i/s
         slim v4.1.0:   383155.0 i/s - 1.05x slower
         haml v5.2.0:   312471.4 i/s - 1.29x slower
       erubi v1.11.0:   310587.9 i/s - 1.29x slower

For fun, I also tested with Ruby 3.2.1 which gave quite a nice speedup:

$ bundle exec ruby -v benchmark/slim/run-benchmarks.rb
ruby 3.2.1 (2023-02-08 revision 31819e82c8) [arm64-darwin21]
Calculating -------------------------------------
       erubi v1.11.0    38.111k i/100ms
         slim v4.1.0    39.468k i/100ms
       hamlit v3.0.2    41.777k i/100ms
         haml v5.2.0    28.209k i/100ms
-------------------------------------------------
       erubi v1.11.0    408.614k (± 1.6%) i/s -      2.058M
         slim v4.1.0    445.191k (± 1.2%) i/s -      2.250M
       hamlit v3.0.2    464.592k (± 1.2%) i/s -      2.340M
         haml v5.2.0    293.733k (± 1.5%) i/s -      1.495M

Comparison:
       hamlit v3.0.2:   464591.8 i/s
         slim v4.1.0:   445190.9 i/s - 1.04x slower
       erubi v1.11.0:   408614.1 i/s - 1.14x slower
         haml v5.2.0:   293733.5 i/s - 1.58x slower

Old results using hamlit 3.0.1 (and without haml 5.2.0 escaping html):

$ bundle exec ruby -v benchmark/slim/run-benchmarks.rb 
ruby 2.6.8p205 (2021-07-07 revision 67951) [arm64-darwin21]
Calculating -------------------------------------
       erubi v1.11.0    29.300k i/100ms
         slim v4.1.0    35.361k i/100ms
       hamlit v3.0.1    31.447k i/100ms
         haml v5.2.0    37.191k i/100ms
-------------------------------------------------
       erubi v1.11.0    309.763k (± 0.2%) i/s -      1.553M
         slim v4.1.0    380.053k (± 0.4%) i/s -      1.909M
       hamlit v3.0.1    335.534k (± 0.1%) i/s -      1.698M
         haml v5.2.0    395.905k (± 1.3%) i/s -      2.008M

Comparison:
         haml v5.2.0:   395905.4 i/s
         slim v4.1.0:   380052.9 i/s - 1.04x slower
       hamlit v3.0.1:   335533.8 i/s - 1.18x slower
       erubi v1.11.0:   309763.0 i/s - 1.28x slower

haml-vs-hamlit-bench's People

Contributors

jontebol avatar

Watchers

 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.