Created
March 24, 2015 19:13
-
-
Save Elffers/9c658d23d8643d202465 to your computer and use it in GitHub Desktop.
SQL/Active Record querying
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 do |x| | |
x.report("sql"){ 5000.times { Person.where(id:2).pluck("created_at").first } } | |
x.report("sql"){ 5000.times { Person.find(2).created_at } } | |
end | |
[#<Benchmark::Tms:0x000001065b1240 | |
@cstime=0.0, | |
@cutime=0.0, | |
@label="sql", | |
@real=1.558864, | |
@stime=0.11000000000000032, | |
@total=1.120000000000001, | |
@utime=1.0100000000000007>, | |
#<Benchmark::Tms:0x007fb6f5aa6d98 | |
@cstime=0.0, | |
@cutime=0.0, | |
@label="sql", | |
@real=2.011806, | |
@stime=0.10999999999999943, | |
@total=1.6899999999999995, | |
@utime=1.58>] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment