Skip to content

Commit

Permalink
Add more examples in performance script.
Browse files Browse the repository at this point in the history
[#5610 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information
miloops authored and jeremy committed Sep 10, 2010
1 parent 68a4b1e commit 61bacc4
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions activerecord/examples/performance.rb
Expand Up @@ -155,6 +155,23 @@ def self.feel(exhibits) exhibits.each { |e| e.feel } end
ar { Exhibit.transaction { Exhibit.new } }
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

Expand Down

0 comments on commit 61bacc4

Please sign in to comment.