Skip to content

Instantly share code, notes, and snippets.

@sgrif
Created November 5, 2014 21:50
Show Gist options
  • Select an option

  • Save sgrif/98c25648c317efd4d0fe to your computer and use it in GitHub Desktop.

Select an option

Save sgrif/98c25648c317efd4d0fe to your computer and use it in GitHub Desktop.
ENV['BUNDLE_GEMFILE'] = File.expand_path('../../rails/Gemfile', __FILE__)
require_relative '../rails/load_paths'
require 'active_record'
require 'active_support/all'
# This connection will do for database-independent bug reports.
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Schema.define do
create_table :users, force: true do |t|
t.string :attribute1
t.string :attribute2
t.string :attribute3
t.string :attribute4
t.string :attribute5
t.string :attribute6
t.string :attribute7
end
end
class User < ActiveRecord::Base; end
# insert 1000 records via seeds
1000.times do
User.create! attribute1: 'foo', attribute2: 'foo', attribute3: 'foo', attribute4: 'foo', attribute5: 'foo', attribute6: 'foo', attribute7: 'foo'
end
require 'benchmark/ips'
puts ActiveRecord.version
puts "User.all.to_a"
# and benchmark
Benchmark.ips do |x|
x.report do
User.all.to_a
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment