Skip to content

Instantly share code, notes, and snippets.

@djbender
Created February 20, 2014 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save djbender/9114435 to your computer and use it in GitHub Desktop.
Save djbender/9114435 to your computer and use it in GitHub Desktop.
AdequateRecord Pro™ (ActiveRecord) Benchmark Example lifted from @tenderlove http://tenderlovemaking.com/2014/02/19/adequaterecord-pro-like-activerecord.html
require 'active_support'
require 'active_record'
p ActiveRecord::VERSION::STRING
ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:'
ActiveRecord::Base.connection.instance_eval do
create_table(:people) { |t| t.string :name }
end
class Person < ActiveRecord::Base; end
person = Person.create! name: 'Aaron'
id = person.id
name = person.name
Benchmark.ips do |x|
x.report('find') { Person.find id }
x.report('find_by_name') { Person.find_by_name name }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment