Created
April 27, 2012 17:36
-
-
Save tenderlove/2511099 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 'active_record' | |
require 'benchmark/ips' | |
ActiveRecord::Base.establish_connection( | |
:adapter => 'sqlite3', | |
:database => ':memory:') | |
ActiveRecord::Base.connection.create_table('posts') do |t| | |
t.string :name | |
t.timestamps | |
end | |
class Post < ActiveRecord::Base | |
end | |
post = Post.create(:name => 'aaron') | |
id = post.id | |
Benchmark.ips do |x| | |
x.report("new") { Post.new } | |
x.report("new args") { Post.new(:name => 'aaron') } | |
x.report("create") { Post.create(:name => 'aaron') } | |
x.report("find") { Post.find(id) } | |
end | |
__END__ | |
3-2-stable: | |
Calculating ------------------------------------- | |
new 1597 i/100ms | |
new args 755 i/100ms | |
create 91 i/100ms | |
find 193 i/100ms | |
------------------------------------------------- | |
new 24843.5 (±8.8%) i/s - 124566 in 5.056542s | |
new args 9188.9 (±9.5%) i/s - 45300 in 4.998662s | |
create 932.8 (±7.3%) i/s - 4641 in 5.002245s | |
find 2066.4 (±5.5%) i/s - 10422 in 5.058268s | |
master: | |
Calculating ------------------------------------- | |
new 2104 i/100ms | |
new args 871 i/100ms | |
create 95 i/100ms | |
find 213 i/100ms | |
------------------------------------------------- | |
new 33856.6 (±7.9%) i/s - 168320 in 5.005236s | |
new args 10681.3 (±7.3%) i/s - 53131 in 5.002680s | |
create 970.3 (±7.0%) i/s - 4845 in 5.019001s | |
find 2207.7 (±7.2%) i/s - 11076 in 5.042719s |
Perhaps because we're not comparing apples to apples. :-)
Looks great!
Thank you for the amazing work.
❤️
❤️
❤️
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
AR, Y U SO SLOW ?