Class: Build::Log

Inherits:
Object
  • Object
show all
Defined in:
lib/core_blur/cost.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLog



16
17
18
19
20
# File 'lib/core_blur/cost.rb', line 16

def initialize
  @cost_array = Array.new
  @start_time = Time.now.getutc.to_i
  @last_time = Time.now.getutc.to_i
end

Instance Attribute Details

#cost_arrayObject

Returns the value of attribute cost_array.



12
13
14
# File 'lib/core_blur/cost.rb', line 12

def cost_array
  @cost_array
end

#cost_timeObject

Returns the value of attribute cost_time.



15
16
17
# File 'lib/core_blur/cost.rb', line 15

def cost_time
  @cost_time
end

#last_timeObject

Returns the value of attribute last_time.



13
14
15
# File 'lib/core_blur/cost.rb', line 13

def last_time
  @last_time
end

#start_timeObject

Returns the value of attribute start_time.



14
15
16
# File 'lib/core_blur/cost.rb', line 14

def start_time
  @start_time
end

Instance Method Details

#end_record_time(description) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/core_blur/cost.rb', line 28

def end_record_time(description)
  current_time =  Time.now.getutc.to_i
  duration = current_time - start_time
  @cost_time = duration
  cost = Cost.new(description, duration)
  cost_array << cost
  @last_time = current_time
end


36
37
38
39
40
41
# File 'lib/core_blur/cost.rb', line 36

def print_cost
  puts "\n⏩ 打印各阶段耗时:"
  cost_array.each do |cost|
    puts "-> #{cost.description}耗时: #{cost.duration}秒"
  end
end

#record_time(description) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/core_blur/cost.rb', line 21

def record_time(description)
  current_time =  Time.now.getutc.to_i
  duration = current_time - last_time
  cost = Cost.new(description, duration)
  cost_array << cost
  @last_time = current_time
end