Sha256: b35fa22ff0cb9e8b6c60b6d42e4c3b059a15673e53a2f7d3cf54170a328d6088

Contents?: true

Size: 577 Bytes

Versions: 6

Compression:

Stored size: 577 Bytes

Contents

class Time
  
  class << self
    
    def log_elapsed(message=nil, &block)
      timer = Time.now
      result = block.call
      message = "#{message} (#{timer.elapsed.microseconds}ms)"
      puts message
      Rails.logger.debug message
      result
    end
  
    def elapsed(message=nil, &block)
      log_elapsed(message, &block)
    end
  
  end
  
  def microseconds
    (self.to_f * 1000.0).to_i
  end
  
  def elapsed
    elapsed_since(Time.now)
  end
  
  def elapsed_since(time)
    time - self
  end
  
  def elapsed_ms
    "#{elapsed.microseconds}ms"
  end
  
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
quandl_operation-0.0.8 lib/quandl/operation/core_ext/time.rb
quandl_operation-0.0.7 lib/quandl/operation/core_ext/time.rb
quandl_operation-0.0.6 lib/quandl/operation/core_ext/time.rb
quandl_operation-0.0.5 lib/quandl/operation/core_ext/time.rb
quandl_operation-0.0.4 lib/quandl/operation/core_ext/time.rb
quandl_operation-0.0.3 lib/quandl/operation/core_ext/time.rb