Create a gist now

Instantly share code, notes, and snippets.

>> require 'active_record'
=> true
>> ActiveRecord::Base.establish_connection(
?> :adapter => "sqlite3",
?> :database => "benchmark.db"
>> )
>> ActiveRecord::Base.connection.execute("DROP TABLE IF EXISTS active_record_models")
>> ActiveRecord::Base.connection.execute("CREATE TABLE active_record_models (id INTEGER UNIQUE, title STRING, text STRING)")
>> class ActiveRecordModel < ActiveRecord::Base
>> end
>> ActiveRecordModel.new
>> require 'benchmark'
# 3.0.7
>> Benchmark.measure { 100_000.times { ActiveRecordModel.new } }
=> 1.470000 0.000000 1.470000 1.474953
# 3.1.0.rc4
>> Benchmark.measure { 100_000.times { ActiveRecordModel.new } }
=> 7.910000 0.050000 7.960000 7.951169
>> Benchmark.measure { 100_000.times { ActiveRecordModel.new(:title => "foo", :text => "bar") } }
=> 15.380000 0.010000 15.390000 15.381160
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment