Created
May 10, 2011 16:18
-
-
Save aberant/964791 to your computer and use it in GitHub Desktop.
find_all_by_id is faster then exceptions
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
Benchmark.bm(10) do |x| | |
x.report("find all") {(1..10000).each { User.find_all_by_id( [99999])}} | |
x.report("find rescue") {(1..10000).each {User.find([9999]) rescue [] }} | |
end | |
user system total real | |
find all 3.200000 0.350000 3.550000 ( 4.630230) | |
find rescue 4.820000 0.380000 5.200000 ( 6.329360) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment