Method: ActiveRecord::Migration#say_with_time

Defined in:
lib/active_record/migration.rb

#say_with_time(message) ⇒ Object

Outputs text along with how long it took to run its block. If the block returns an integer it assumes it is the number of rows affected.



1018
1019
1020
1021
1022
1023
1024
1025
# File 'lib/active_record/migration.rb', line 1018

def say_with_time(message)
  say(message)
  result = nil
  time_elapsed = ActiveSupport::Benchmark.realtime { result = yield }
  say "%.4fs" % time_elapsed, :subitem
  say("#{result} rows", :subitem) if result.is_a?(Integer)
  result
end