Module: OccamsRecord::Measureable
Overview
Measure the time each query takes. Useful for figuring out which query is the slow one when you're doing a bunch of eager loads.
orders = OccamsRecord .query(Order.all) .eager_load(:customer) ... .measure { |x| puts "Total time: #xx.total_time sec" x.queries.each { |q| puts "Table: #qq.table_name (#qq.time sec)" puts q.sql } } .run
Instance Method Summary collapse
-
#measure {|OccamsRecord::Measurements| ... } ⇒ Object
Track the run time of each query, and the total run time of everything combined.
Instance Method Details
#measure {|OccamsRecord::Measurements| ... } ⇒ Object
Track the run time of each query, and the total run time of everything combined.
28 29 30 31 32 |
# File 'lib/occams-record/measureable.rb', line 28 def measure(&block) @measurements ||= [] @measurement_results_block = block self end |