Skip to content

Instantly share code, notes, and snippets.

@spastorino
Created October 13, 2010 16:26
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 spastorino/624387 to your computer and use it in GitHub Desktop.
Save spastorino/624387 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby -KU
TIMES = 100000
require 'rubygems'
gem 'addressable', '~>2.0'
gem 'faker', '~>0.3.1'
gem 'rbench', '~>0.2.3'
require 'addressable/uri'
require 'faker'
require 'rbench'
require File.expand_path("../../../load_paths", __FILE__)
require "active_record"
conn = { :adapter => 'sqlite3',
:database => 'testing.sqlite3',
:pool => 5,
:timeout => 5000 }
ActiveRecord::Base.establish_connection(conn)
class User < ActiveRecord::Base
connection.create_table :users, :force => true do |t|
t.string :name, :email
t.timestamps
end
end
RBench.run(TIMES) do
report 'Model#find_by_id' do
User.find_by_id(1)
end
end
ActiveRecord::Migration.drop_table "users"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment