Closed k0kubun closed 8 years ago
No effect for performance. ¯_(ツ)_/¯
=================================================
Compilation: test/haml/templates/standard.haml
=================================================
Calculating -------------------------------------
haml v4.1.0.beta.1 48.000 i/100ms
faml v0.8.1 22.000 i/100ms
hamlit v2.6.1 18.000 i/100ms
-------------------------------------------------
haml v4.1.0.beta.1 482.724 i/s (2.072ms) - 2.448k
faml v0.8.1 220.218 i/s (4.541ms) - 1.122k
hamlit v2.6.1 179.144 i/s (5.582ms) - 900.000
Comparison:
haml v4.1.0.beta.1: 482.7 i/s (2.072ms)
faml v0.8.1: 220.2 i/s (4.541ms) - 2.19x slower
hamlit v2.6.1: 179.1 i/s (5.582ms) - 2.69x slower
=================================================
Compilation: test/haml/templates/standard.haml
=================================================
Calculating -------------------------------------
haml v4.1.0.beta.1 47.000 i/100ms
faml v0.8.1 22.000 i/100ms
hamlit v2.6.1 17.000 i/100ms
-------------------------------------------------
haml v4.1.0.beta.1 471.825 i/s (2.119ms) - 2.397k
faml v0.8.1 223.487 i/s (4.475ms) - 1.122k
hamlit v2.6.1 177.999 i/s (5.618ms) - 901.000
Comparison:
haml v4.1.0.beta.1: 471.8 i/s (2.119ms)
faml v0.8.1: 223.5 i/s (4.475ms) - 2.11x slower
hamlit v2.6.1: 178.0 i/s (5.618ms) - 2.65x slower
Version of ruby are you using?
frozen_string_literal: true
>= Ruby 2.3
The result is benchmarked by Ruby 2.3.1 on Travis. https://travis-ci.org/k0kubun/hamlit/jobs/155382106 https://travis-ci.org/k0kubun/hamlit/jobs/155408830
Hamlit is using frozen string literal in its source code to optimize compilation. Since Ruby 2.3 may be widely used now, I prefer
frozen_string_literal: true
rather than appending.freeze
to all string literals.