Created
June 11, 2020 13:01
-
-
Save czj/911df1a56f4409dc32bc5529a3f26638 to your computer and use it in GitHub Desktop.
Benchmarking Rails' `content_tag(:b)` vs `tag.b`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
before = Process.clock_gettime(Process::CLOCK_MONOTONIC) | |
50_000.times { tag.span("hey") } | |
after = Process.clock_gettime(Process::CLOCK_MONOTONIC) | |
Rails.logger.debug %(tag.span("hey") } #{after - before}s) | |
before = Process.clock_gettime(Process::CLOCK_MONOTONIC) | |
50_000.times { tag.span { "hey" } } | |
after = Process.clock_gettime(Process::CLOCK_MONOTONIC) | |
Rails.logger.debug %(tag.span { "hey" } } #{after - before}s) | |
before = Process.clock_gettime(Process::CLOCK_MONOTONIC) | |
50_000.times { content_tag(:span, "hey") } | |
after = Process.clock_gettime(Process::CLOCK_MONOTONIC) | |
Rails.logger.debug %(content_tag(:span, "hey") } #{after - before}s) | |
before = Process.clock_gettime(Process::CLOCK_MONOTONIC) | |
50_000.times { content_tag(:span) { "hey" } } | |
after = Process.clock_gettime(Process::CLOCK_MONOTONIC) | |
Rails.logger.debug %(content_tag(:span) { "hey" } } #{after - before}s) | |
before = Process.clock_gettime(Process::CLOCK_MONOTONIC) | |
50_000.times { tag_builder.content_tag_string(:span, "hey", nil) } | |
after = Process.clock_gettime(Process::CLOCK_MONOTONIC) | |
Rails.logger.debug %(tag_builder.content_tag_string(:span, "hey", nil) } #{after - before}s) | |
Rails.logger.debug %(50_000.times { tag.span("hey") } }) | |
Rails.logger.debug(Benchmark.ms { 50_000.times { tag.span("hey") } }) | |
Rails.logger.debug %(50_000.times { tag.span { "hey" } } }) | |
Rails.logger.debug(Benchmark.ms { 50_000.times { tag.span { "hey" } } }) | |
Rails.logger.debug %(50_000.times { content_tag(:span, "hey") } }) | |
Rails.logger.debug(Benchmark.ms { 50_000.times { content_tag(:span, "hey") } }) | |
Rails.logger.debug %(50_000.times { content_tag(:span) { "hey" } } }) | |
Rails.logger.debug(Benchmark.ms { 50_000.times { content_tag(:span) { "hey" } } }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment