public
Created

  • Download Gist
perf.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.