Created
July 22, 2011 04:13
-
-
Save kaichen/1098870 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| require "rubygems" | |
| require "active_record" | |
| require "squeel" | |
| n = 5000 | |
| conn = { :adapter => 'sqlite3', :database => ':memory:' } | |
| ActiveRecord::Base.establish_connection(conn) | |
| class User < ActiveRecord::Base | |
| connection.create_table :users, :force => true do |t| | |
| t.string :name, :email | |
| end | |
| end | |
| User.create :name => "Joe Blow", :email => "[email protected]" | |
| User.create :name => "Jack Nack", :email => "[email protected]" | |
| User.create :name => "Gerdon Don", :email => "[email protected]" | |
| Benchmark.bmbm do |x| | |
| x.report("w/o squeel") { for i in 1..n; User.where(:name => 'Joe Blow'); end } | |
| x.report("w/ squeel") { for i in 1..n; User.where{name.eq 'Joe Blow'}; end } | |
| end | |
| #=> | |
| # user system total real | |
| # w/o squeel 0.100000 0.000000 0.100000 ( 0.109199) | |
| # w/ squeel 0.220000 0.010000 0.230000 ( 0.253682) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment