Class: Pwrake::Timer

Inherits:
Object
  • Object
show all
Defined in:
lib/pwrake/timer.rb

Instance Method Summary collapse

Constructor Details

#initialize(prefix, *extra) ⇒ Timer

Returns a new instance of Timer.



5
6
7
8
9
10
11
# File 'lib/pwrake/timer.rb', line 5

def initialize(prefix,*extra)
  @prefix = prefix
  @start_time = Time.now
  str = "%s[start]:%s %s" %
    [@prefix, Log.fmt_time(@start_time), extra.join(' ')]
  Log.info(str)
end

Instance Method Details

#finish(*extra) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/pwrake/timer.rb', line 13

def finish(*extra)
  end_time = Time.now
  elap_time = end_time - @start_time
  str = "%s[end]:%s elap=%.3f %s" %
    [@prefix, Log.fmt_time(end_time), elap_time, extra.join(' ')]
  Log.info(str)
end