Last active
August 29, 2015 14:11
-
-
Save nmeylan/f050d2354f31056097c8 to your computer and use it in GitHub Desktop.
issue_benchmark_script
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
ENV['RAILS_ENV'] = 'development' | |
require File.expand_path('../../config/environment', __FILE__) | |
RAILS_VERSION = Rails.version | |
ITERATIONS = 5 | |
# Database contains : | |
# 10_000 issues | |
# 30 categories | |
# 3 trackers | |
# 3 nested_relations | |
Benchmark.bm(40) do |bm| | |
ITERATIONS.times do |time| | |
puts "\nIteration n: #{time + 1}" | |
issues = Issue.all.includes(:category, tracker: :nested_relation) # To bypass cache | |
bm.report("Rails #{RAILS_VERSION} : 1 relation") do | |
issues.each do |issue| | |
caption = issue.tracker.name | |
end | |
end | |
issues = Issue.all.includes(:category, tracker: :nested_relation) # To bypass cache | |
bm.report("Rails #{RAILS_VERSION} : 2 relations") do | |
issues.each do |issue| | |
caption = issue.tracker.name | |
caption1 = issue.category.name | |
end | |
end | |
issues = Issue.all.includes(:category, tracker: :nested_relation) # To bypass cache | |
bm.report("Rails #{RAILS_VERSION} : 1 nested relation") do | |
issues.each do |issue| | |
caption1 = issue.tracker.nested_relation.name | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment