Skip to content

Instantly share code, notes, and snippets.

@teeparham
Last active April 19, 2017 17:38
Show Gist options
  • Save teeparham/33e5a07b68c312c27521bf985ec40077 to your computer and use it in GitHub Desktop.
Save teeparham/33e5a07b68c312c27521bf985ec40077 to your computer and use it in GitHub Desktop.
rails rendering analysis
$ time { render "haml" }
Rendered _haml.html.haml (0.5ms)
----> 1.51 ms
$ time { render "erb" }
Rendered _erb.html.erb (0.4ms)
----> 1.78 ms
# using hamlit
# there is little difference in rendering erb & haml
$ time { render text: content_tag(:li, link_to(t(:sign_up), signin_path)) }
Rendered text template (0.0ms)
----> 0.54 ms
# >>>
# the partial file lookup is MUCH slower than the actual template rendering
$ xx = content_tag(:li, link_to(t(:sign_up), signin_path))
"<li><a href=\"/signin\">Sign up</a></li>"
$ time { render text: xx }
Rendered text template (0.0ms)
----> 0.38 ms
$ time { render text: xx }
Rendered text template (0.0ms)
----> 0.25 ms
$ time { render text: content_tag(:li, "<a href='/signin'>Sign up</a>") }
Rendered text template (0.0ms)
----> 0.28 ms
$ time { render text: ("<li><a href='/signin'>Sign up</a></li>") }
Rendered text template (0.0ms)
----> 0.19 ms
# render: 0.2 ms
# content_tag / link_to: 0.1 ms
# template file lookup: 1.0 ms
# haml / erb rendering: 0.2 ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment