Skip to content

Instantly share code, notes, and snippets.

@paul
Created June 14, 2011 21:41
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 paul/fabfaf1bd8503fbf6d32 to your computer and use it in GitHub Desktop.
Save paul/fabfaf1bd8503fbf6d32 to your computer and use it in GitHub Desktop.
>> 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