Skip to content

Instantly share code, notes, and snippets.

@jenny-codes
Last active February 19, 2019 05:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jenny-codes/4cc9cb1747f3a2ce2f393282fdaf2ffc to your computer and use it in GitHub Desktop.
Save jenny-codes/4cc9cb1747f3a2ce2f393282fdaf2ffc to your computer and use it in GitHub Desktop.
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