Skip to content

Commit

Permalink
slim
Browse files Browse the repository at this point in the history
  • Loading branch information
sebyx07 committed Aug 17, 2024
1 parent 23066cf commit d2883a9
Show file tree
Hide file tree
Showing 11 changed files with 131 additions and 155 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.3
3.3.4
71 changes: 0 additions & 71 deletions Dockerfile

This file was deleted.

4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ gem 'capybara', '~> 3.40'

gem 'lefthook', '~> 1.7'

gem 'faker'
gem 'faker', '~> 3.4', '>= 3.4.2'

gem 'slim-rails', '~> 3.6', '>= 3.6.3'

group :test do
gem 'benchmark-ips'
Expand Down
150 changes: 80 additions & 70 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (7.2.0.rc1)
actionpack (= 7.2.0.rc1)
activesupport (= 7.2.0.rc1)
actioncable (7.2.0)
actionpack (= 7.2.0)
activesupport (= 7.2.0)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
zeitwerk (~> 2.6)
actionmailbox (7.2.0.rc1)
actionpack (= 7.2.0.rc1)
activejob (= 7.2.0.rc1)
activerecord (= 7.2.0.rc1)
activestorage (= 7.2.0.rc1)
activesupport (= 7.2.0.rc1)
actionmailbox (7.2.0)
actionpack (= 7.2.0)
activejob (= 7.2.0)
activerecord (= 7.2.0)
activestorage (= 7.2.0)
activesupport (= 7.2.0)
mail (>= 2.8.0)
actionmailer (7.2.0.rc1)
actionpack (= 7.2.0.rc1)
actionview (= 7.2.0.rc1)
activejob (= 7.2.0.rc1)
activesupport (= 7.2.0.rc1)
actionmailer (7.2.0)
actionpack (= 7.2.0)
actionview (= 7.2.0)
activejob (= 7.2.0)
activesupport (= 7.2.0)
mail (>= 2.8.0)
rails-dom-testing (~> 2.2)
actionpack (7.2.0.rc1)
actionview (= 7.2.0.rc1)
activesupport (= 7.2.0.rc1)
actionpack (7.2.0)
actionview (= 7.2.0)
activesupport (= 7.2.0)
nokogiri (>= 1.8.5)
racc
rack (>= 2.2.4, < 3.2)
Expand All @@ -32,35 +32,35 @@ GEM
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
useragent (~> 0.16)
actiontext (7.2.0.rc1)
actionpack (= 7.2.0.rc1)
activerecord (= 7.2.0.rc1)
activestorage (= 7.2.0.rc1)
activesupport (= 7.2.0.rc1)
actiontext (7.2.0)
actionpack (= 7.2.0)
activerecord (= 7.2.0)
activestorage (= 7.2.0)
activesupport (= 7.2.0)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.2.0.rc1)
activesupport (= 7.2.0.rc1)
actionview (7.2.0)
activesupport (= 7.2.0)
builder (~> 3.1)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
activejob (7.2.0.rc1)
activesupport (= 7.2.0.rc1)
activejob (7.2.0)
activesupport (= 7.2.0)
globalid (>= 0.3.6)
activemodel (7.2.0.rc1)
activesupport (= 7.2.0.rc1)
activerecord (7.2.0.rc1)
activemodel (= 7.2.0.rc1)
activesupport (= 7.2.0.rc1)
activemodel (7.2.0)
activesupport (= 7.2.0)
activerecord (7.2.0)
activemodel (= 7.2.0)
activesupport (= 7.2.0)
timeout (>= 0.4.0)
activestorage (7.2.0.rc1)
actionpack (= 7.2.0.rc1)
activejob (= 7.2.0.rc1)
activerecord (= 7.2.0.rc1)
activesupport (= 7.2.0.rc1)
activestorage (7.2.0)
actionpack (= 7.2.0)
activejob (= 7.2.0)
activerecord (= 7.2.0)
activesupport (= 7.2.0)
marcel (~> 1.0)
activesupport (7.2.0.rc1)
activesupport (7.2.0)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
Expand Down Expand Up @@ -93,7 +93,7 @@ GEM
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
coderay (1.1.3)
concurrent-ruby (1.3.3)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
crass (1.0.6)
date (3.3.4)
Expand All @@ -113,7 +113,7 @@ GEM
reline (>= 0.4.2)
json (2.7.2)
language_server-protocol (3.17.0.3)
lefthook (1.7.12)
lefthook (1.7.14)
logger (1.6.0)
loofah (2.22.0)
crass (~> 1.0.2)
Expand All @@ -127,7 +127,7 @@ GEM
matrix (0.4.2)
method_source (1.1.0)
mini_mime (1.1.5)
minitest (5.24.1)
minitest (5.25.1)
msgpack (1.7.2)
net-imap (0.4.14)
date
Expand All @@ -149,8 +149,8 @@ GEM
racc (~> 1.4)
nokogiri (1.16.7-x86_64-linux)
racc (~> 1.4)
parallel (1.25.1)
parser (3.3.4.1)
parallel (1.26.3)
parser (3.3.4.2)
ast (~> 2.4.1)
racc
pry (0.14.2)
Expand All @@ -172,30 +172,30 @@ GEM
rackup (2.1.0)
rack (>= 3)
webrick (~> 1.8)
rails (7.2.0.rc1)
actioncable (= 7.2.0.rc1)
actionmailbox (= 7.2.0.rc1)
actionmailer (= 7.2.0.rc1)
actionpack (= 7.2.0.rc1)
actiontext (= 7.2.0.rc1)
actionview (= 7.2.0.rc1)
activejob (= 7.2.0.rc1)
activemodel (= 7.2.0.rc1)
activerecord (= 7.2.0.rc1)
activestorage (= 7.2.0.rc1)
activesupport (= 7.2.0.rc1)
rails (7.2.0)
actioncable (= 7.2.0)
actionmailbox (= 7.2.0)
actionmailer (= 7.2.0)
actionpack (= 7.2.0)
actiontext (= 7.2.0)
actionview (= 7.2.0)
activejob (= 7.2.0)
activemodel (= 7.2.0)
activerecord (= 7.2.0)
activestorage (= 7.2.0)
activesupport (= 7.2.0)
bundler (>= 1.15.0)
railties (= 7.2.0.rc1)
railties (= 7.2.0)
rails-dom-testing (2.2.0)
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
railties (7.2.0.rc1)
actionpack (= 7.2.0.rc1)
activesupport (= 7.2.0.rc1)
railties (7.2.0)
actionpack (= 7.2.0)
activesupport (= 7.2.0)
irb (~> 1.13)
rackup (>= 1.0.0)
rake (>= 12.2)
Expand All @@ -208,7 +208,7 @@ GEM
regexp_parser (2.9.2)
reline (0.5.9)
io-console (~> 0.5)
rexml (3.3.4)
rexml (3.3.5)
strscan
rspec-core (3.13.0)
rspec-support (~> 3.13.0)
Expand All @@ -218,7 +218,7 @@ GEM
rspec-mocks (3.13.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-rails (6.1.3)
rspec-rails (6.1.4)
actionpack (>= 6.1)
activesupport (>= 6.1)
railties (>= 6.1)
Expand Down Expand Up @@ -270,25 +270,34 @@ GEM
rubocop-rails (~> 2.0)
ruby-progressbar (1.13.0)
securerandom (0.3.1)
slim (5.2.1)
temple (~> 0.10.0)
tilt (>= 2.1.0)
slim-rails (3.6.3)
actionpack (>= 3.1)
railties (>= 3.1)
slim (>= 3.0, < 6.0, != 5.0.0)
sprockets (4.2.1)
concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4)
sprockets-rails (3.5.2)
actionpack (>= 6.1)
activesupport (>= 6.1)
sprockets (>= 3.0.0)
sqlite3 (2.0.3-aarch64-linux-gnu)
sqlite3 (2.0.3-aarch64-linux-musl)
sqlite3 (2.0.3-arm-linux-gnu)
sqlite3 (2.0.3-arm-linux-musl)
sqlite3 (2.0.3-arm64-darwin)
sqlite3 (2.0.3-x86-linux-gnu)
sqlite3 (2.0.3-x86-linux-musl)
sqlite3 (2.0.3-x86_64-linux-gnu)
sqlite3 (2.0.3-x86_64-linux-musl)
sqlite3 (2.0.4-aarch64-linux-gnu)
sqlite3 (2.0.4-aarch64-linux-musl)
sqlite3 (2.0.4-arm-linux-gnu)
sqlite3 (2.0.4-arm-linux-musl)
sqlite3 (2.0.4-arm64-darwin)
sqlite3 (2.0.4-x86-linux-gnu)
sqlite3 (2.0.4-x86-linux-musl)
sqlite3 (2.0.4-x86_64-linux-gnu)
sqlite3 (2.0.4-x86_64-linux-musl)
stringio (3.1.1)
strscan (3.1.0)
temple (0.10.3)
thor (1.3.1)
tilt (2.4.0)
timeout (0.4.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
Expand Down Expand Up @@ -331,7 +340,7 @@ DEPENDENCIES
bootsnap
brakeman
capybara (~> 3.40)
faker
faker (~> 3.4, >= 3.4.2)
htmlbeautifier
lefthook (~> 1.7)
pry-rails (~> 0.3.11)
Expand All @@ -340,6 +349,7 @@ DEPENDENCIES
rspec-rails (~> 6.1, >= 6.1.3)
rubocop-rails-omakase
rubocop-rails_config (~> 1.16)
slim-rails (~> 3.6, >= 3.6.3)
sprockets-rails
sqlite3 (>= 1.4)
tzinfo-data
Expand Down
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,21 +101,26 @@ Replace your ERB with beautiful Ruby code:
### Benchmark

```bash
ruby 3.3.3 (2024-06-12 revision f1c7b6f435) +YJIT [x86_64-linux]
ruby 3.3.4 (2024-07-09 revision be1089c8ec) +YJIT [x86_64-linux]
Warming up --------------------------------------
GET /benchmark/html (ERB)
2.000 i/100ms
1.000 i/100ms
GET /benchmark/ruby (Ruby2html)
1.000 i/100ms
GET /benchmark/slim (Slim)
1.000 i/100ms
Calculating -------------------------------------
GET /benchmark/html (ERB)
20.989 (±19.1%) i/s - 102.000 in 5.077353s
20.226 (±19.8%) i/s - 1.147k in 60.029983s
GET /benchmark/ruby (Ruby2html)
20.438 (±19.6%) i/s - 97.000 in 5.010249s
18.628 (±16.1%) i/s - 1.065k in 60.036596s
GET /benchmark/slim (Slim)
20.237 (±19.8%) i/s - 1.149k in 60.024886s

Comparison:
GET /benchmark/html (ERB): 21.0 i/s
GET /benchmark/ruby (Ruby2html): 20.4 i/s - same-ish: difference falls within error
GET /benchmark/slim (Slim): 20.2 i/s
GET /benchmark/html (ERB): 20.2 i/s - same-ish: difference falls within error
GET /benchmark/ruby (Ruby2html): 18.6 i/s - same-ish: difference falls within error
```

### With ViewComponents
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/benchmark_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ def ruby_2html
@complex_data = generate_complex_data
end

def slim_html
@complex_data = generate_complex_data
end

private
def generate_complex_data
{
Expand Down
Loading

0 comments on commit d2883a9

Please sign in to comment.