Skip to content

Instantly share code, notes, and snippets.

@bogdan
Created March 15, 2012 09:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bogdan/2043384 to your computer and use it in GitHub Desktop.
Save bogdan/2043384 to your computer and use it in GitHub Desktop.
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