File: active_support/core_ext/benchmark.rb

Code

Code

   1  require 'benchmark'
   2 
   3  class << Benchmark
   4    # Earlier Ruby had a slower implementation.
   5    if RUBY_VERSION < '1.8.7'
   6      remove_method :realtime
   7 
   8      def realtime
   9        r0 = Time.now
  10        yield
  11        r1 = Time.now
  12        r1.to_f - r0.to_f
  13      end
  14    end
  15 
  16    def ms
  17      1000 * realtime { yield }
  18    end
  19  end