Created
February 24, 2015 09:08
-
-
Save splattael/b22a124a13fc5d3cc1ac to your computer and use it in GitHub Desktop.
ROM benchmark
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
#!/usr/bin/env ruby | |
# encoding: utf-8 | |
require_relative 'setup' | |
run "Loading ONE user object" do |x| | |
x.expect { |user| user.name == 'name 1' } | |
x.report("AR") { ARUser.by_name('name 1').first } | |
x.report("ROM") { users.by_name('name 1').first } | |
end | |
run "Loading ALL user objects" do |x| | |
x.expect { |users| users.size == COUNT } | |
x.report("AR") { ARUser.all.to_a } | |
x.report("ROM") { users.all.to_a } | |
end | |
run "Loading ALL users with their tasks" do |x| | |
x.expect { |users| users.size == COUNT } | |
x.report("AR") { ARUser.all.includes(:tasks).to_a } | |
x.report("ROM") { users.all.with_tasks.to_a } | |
end | |
run "Loading ONE task with its user and tags" do |x| | |
x.expect { |task| task.name == 'task 1' } | |
x.report("AR") { ARTask.all.includes(:user).includes(:tags).first } | |
x.report("ROM") { tasks.with_user.with_tags.by_title('task 1').first } | |
end | |
run "Loading ALL tasks with their users" do |x| | |
x.expect { |tasks| tasks.size == COUNT } | |
x.report("AR") { ARTask.all.includes(:user).to_a } | |
x.report("ROM") { tasks.with_user.to_a } | |
end | |
run "Loading ALL tasks with their users and tags" do |x| | |
x.expect { |tasks| tasks.size == COUNT } | |
x.report("AR") { ARTask.all.includes(:user).includes(:tags).to_a } | |
x.report("ROM") { tasks.all.with_user.with_tags.to_a } | |
end | |
run("to_json on ALL user objects") do |x| | |
x.expect { |json| JSON(json).size == COUNT } | |
x.report("AR") { ARUser.all.to_a.to_json } | |
x.report("ROM") { users.all.to_a.to_json } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment