Created
March 15, 2012 09:55
-
-
Save bogdan/2043384 to your computer and use it in GitHub Desktop.
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
require "diffbench" | |
$LOAD_PATH.unshift "./lib" | |
$LOAD_PATH.unshift "../activemodel/lib" | |
require 'active_model' | |
require 'active_model/configuration' | |
ActiveModel::Configuration | |
require "active_record" | |
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:") | |
ActiveRecord::Base.configurations = true | |
ActiveRecord::Base.logger = nil | |
ActiveRecord::Schema.verbose = false | |
ActiveRecord::Schema.define(:version => 1) do | |
create_table :entries do |t| | |
t.integer :group_id | |
t.string :name | |
t.string :category | |
t.boolean :disabled, :null => false, :default => false | |
t.boolean :confirmed, :null => false, :default => false | |
t.date :shipping_date | |
t.timestamps | |
end | |
class ::Entry < ActiveRecord::Base | |
end | |
end | |
e = Entry.new | |
amount = 10000 | |
DiffBench.bm do | |
report("simple initialize") do | |
amount.times do | |
Entry.new | |
end | |
end | |
report("initialize with attributes") do | |
amount.times do | |
Entry.new(:group_id => 1) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment