Skip to content

@bogdan /perf.rb
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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
Something went wrong with that request. Please try again.