Class: Logger::Benchmarker

Inherits:
Object show all
Defined in:
lib/core-extensions/benchmark-logger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(msg, severity = :warn) ⇒ Benchmarker

Returns a new instance of Benchmarker.



8
9
10
11
# File 'lib/core-extensions/benchmark-logger.rb', line 8

def initialize(msg, severity = :warn)
  @msg, @start = msg, Time.now
  @severity = severity
end

Instance Attribute Details

#msgObject

Returns the value of attribute msg.



5
6
7
# File 'lib/core-extensions/benchmark-logger.rb', line 5

def msg
  @msg
end

#severityObject

Returns the value of attribute severity.



6
7
8
# File 'lib/core-extensions/benchmark-logger.rb', line 6

def severity
  @severity
end

Instance Method Details

#runtimeObject



13
14
15
# File 'lib/core-extensions/benchmark-logger.rb', line 13

def runtime
  Time.now - @start
end

#to_sObject



17
18
19
# File 'lib/core-extensions/benchmark-logger.rb', line 17

def to_s
  "#{msg}: #{(runtime * 1000).to_i} msecs" 
end