Skip to content
Browse files

Add examples to performance script that were included in version 3.

  • Loading branch information...
1 parent 1851596 commit 5a63df211d2a07c556720de688ede93fdf22efd0 @miloops miloops committed Sep 30, 2010
Showing with 17 additions and 0 deletions.
  1. +17 −0 activerecord/examples/performance.rb
View
17 activerecord/examples/performance.rb
@@ -174,6 +174,23 @@ def self.feel(exhibits) exhibits.each { |e| e.feel } end
ar { ActiveRecord::Base.connection.execute("Select * from exhibits where id = #{(rand * 1000 + 1).to_i}") }
end
+ report 'Model.find(id)' do
+ id = Exhibit.first.id
+ ar { Exhibit.find(id) }
+ end
+
+ report 'Model.find_by_sql' do
+ ar { Exhibit.find_by_sql("SELECT * FROM exhibits WHERE id = #{(rand * 1000 + 1).to_i}").first }
+ end
+
+ report 'Model.log', (TIMES * 10) do
+ ar { Exhibit.connection.send(:log, "hello", "world") {} }
+ end
+
+ report 'AR.execute(query)', (TIMES / 2) do
+ ar { ActiveRecord::Base.connection.execute("Select * from exhibits where id = #{(rand * 1000 + 1).to_i}") }
+ end
+
summary 'Total'
end

0 comments on commit 5a63df2

Please sign in to comment.
Something went wrong with that request. Please try again.