An error occurred while fetching this tab.
Execute specific named route method from toggle_award_url helper method
- Oct 18, 2016
-
-
Paco Guzmán authored
-
Use specific named route method because this helper method is called a lot of times in pages with a lot of discussions.
require 'benchmark/ips'
project = Project.find_with_namespace("gitlab-org/gitlab-ce")
project.namespace # Association load
namespace = project.namespace.becomes(Namespace)
note = project.notes.last
Benchmark.ips do |x|
x.report("current") do
app.url_for([:toggle_award_emoji, project.namespace.becomes(Namespace), project, note])
end
x.report("inter1") do
app.url_for([:toggle_award_emoji, namespace, project, note])
end
x.report("inter2") do
app.toggle_award_emoji_namespace_project_note_url(namespace, project, note)
end
x.report("new") do
app.toggle_award_emoji_namespace_project_note_url(namespace_id: project.namespace_id, project_id: project.id, id: note.id)
end
x.compare!
end
Calculating -------------------------------------
current 164.000 i/100ms
inter1 358.000 i/100ms
inter2 749.000 i/100ms
new 956.000 i/100ms
-------------------------------------------------
current 1.625k (± 8.1%) i/s - 8.200k
inter1 3.657k (± 6.3%) i/s - 18.258k
inter2 7.784k (± 8.3%) i/s - 38.948k
new 9.821k (± 9.3%) i/s - 48.756k
Comparison:
new: 9821.4 i/s
inter2: 7783.6 i/s - 1.26x slower
inter1: 3656.5 i/s - 2.69x slower
current: 1624.6 i/s - 6.05x slower
master
(if it does - rebase it please)Relates with #23241 (moved) and #23226 (moved)