Skip to content

Instantly share code, notes, and snippets.

@jenny-codes
Last active February 19, 2019 05:50
Embed
What would you like to do?
Benchmarking performances between :preload, :eager_load, :includes
require 'benchmark/ips'
def test
Benchmark.ips do |bm|
bm.report('#preload ') do
Speaker.preload(:talks).to_a
end
bm.report('#eager_load') do
Speaker.eager_load(:talks).to_a
end
bm.report('#includes ') do
Speaker.includes(:talks).to_a
end
bm.compare!
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment