aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/examples/performance.rb
diff options
context:
space:
mode:
authorGuillermo Iguaran <guilleiguaran@gmail.com>2013-06-23 22:50:55 -0700
committerGuillermo Iguaran <guilleiguaran@gmail.com>2013-06-23 22:50:55 -0700
commitc0714a969d85ca8ffb2371c34e770ea1b61eb2ec (patch)
treeb01e0af257ce97127c1817bcc71a5ba10758225d /activerecord/examples/performance.rb
parent11ac1e8a2ce9b12fce829088e1000328687d0cf4 (diff)
parentcbd4a2e3178f16a7c363035a111093692bece379 (diff)
downloadrails-c0714a969d85ca8ffb2371c34e770ea1b61eb2ec.tar.gz
rails-c0714a969d85ca8ffb2371c34e770ea1b61eb2ec.tar.bz2
rails-c0714a969d85ca8ffb2371c34e770ea1b61eb2ec.zip
Merge pull request #11067 from rajars2576/fix_older_rocket
replace all older rocket sign to new ":" from examples of active record ...
Diffstat (limited to 'activerecord/examples/performance.rb')
-rw-r--r--activerecord/examples/performance.rb32
1 files changed, 16 insertions, 16 deletions
diff --git a/activerecord/examples/performance.rb b/activerecord/examples/performance.rb
index ad12f8597f..1f23b13cac 100644
--- a/activerecord/examples/performance.rb
+++ b/activerecord/examples/performance.rb
@@ -5,12 +5,12 @@ require 'benchmark/ips'
TIME = (ENV['BENCHMARK_TIME'] || 20).to_i
RECORDS = (ENV['BENCHMARK_RECORDS'] || TIME*1000).to_i
-conn = { :adapter => 'sqlite3', :database => ':memory:' }
+conn = { adapter: 'sqlite3', database: ':memory:' }
ActiveRecord::Base.establish_connection(conn)
class User < ActiveRecord::Base
- connection.create_table :users, :force => true do |t|
+ connection.create_table :users, force: true do |t|
t.string :name, :email
t.timestamps
end
@@ -19,7 +19,7 @@ class User < ActiveRecord::Base
end
class Exhibit < ActiveRecord::Base
- connection.create_table :exhibits, :force => true do |t|
+ connection.create_table :exhibits, force: true do |t|
t.belongs_to :user
t.string :name
t.text :notes
@@ -77,28 +77,28 @@ today = Date.today
puts "Inserting #{RECORDS} users and exhibits..."
RECORDS.times do
user = User.create(
- :created_at => today,
- :name => ActiveRecord::Faker.name,
- :email => ActiveRecord::Faker.email
+ created_at: today,
+ name: ActiveRecord::Faker.name,
+ email: ActiveRecord::Faker.email
)
Exhibit.create(
- :created_at => today,
- :name => ActiveRecord::Faker.name,
- :user => user,
- :notes => notes
+ created_at: today,
+ name: ActiveRecord::Faker.name,
+ user: user,
+ notes: notes
)
end
Benchmark.ips(TIME) do |x|
ar_obj = Exhibit.find(1)
- attrs = { :name => 'sam' }
- attrs_first = { :name => 'sam' }
- attrs_second = { :name => 'tom' }
+ attrs = { name: 'sam' }
+ attrs_first = { name: 'sam' }
+ attrs_second = { name: 'tom' }
exhibit = {
- :name => ActiveRecord::Faker.name,
- :notes => notes,
- :created_at => Date.today
+ name: ActiveRecord::Faker.name,
+ notes: notes,
+ :created_at: Date.today
}
x.report("Model#id") do