Class: Build::Log
- Inherits:
-
Object
- Object
- Build::Log
- Defined in:
- lib/core_blur/cost.rb
Instance Attribute Summary collapse
-
#cost_array ⇒ Object
Returns the value of attribute cost_array.
-
#cost_time ⇒ Object
Returns the value of attribute cost_time.
-
#last_time ⇒ Object
Returns the value of attribute last_time.
-
#start_time ⇒ Object
Returns the value of attribute start_time.
Instance Method Summary collapse
- #end_record_time(description) ⇒ Object
-
#initialize ⇒ Log
constructor
A new instance of Log.
- #print_cost ⇒ Object
- #record_time(description) ⇒ Object
Constructor Details
#initialize ⇒ Log
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_array ⇒ Object
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_time ⇒ Object
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_time ⇒ Object
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_time ⇒ Object
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 |
#print_cost ⇒ Object
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 |