Class: Knapsack::Tracker
- Inherits:
-
Object
- Object
- Knapsack::Tracker
- Includes:
- Singleton
- Defined in:
- lib/knapsack/tracker.rb
Instance Attribute Summary collapse
-
#global_time ⇒ Object
readonly
Returns the value of attribute global_time.
-
#spec_files_with_time ⇒ Object
readonly
Returns the value of attribute spec_files_with_time.
- #spec_path ⇒ Object
Instance Method Summary collapse
- #config(opts = {}) ⇒ Object
- #exceeded_time ⇒ Object
-
#initialize ⇒ Tracker
constructor
A new instance of Tracker.
- #max_node_time_execution ⇒ Object
- #reset! ⇒ Object
- #start_timer ⇒ Object
- #stop_timer ⇒ Object
- #time_exceeded? ⇒ Boolean
Constructor Details
#initialize ⇒ Tracker
Returns a new instance of Tracker.
8 9 10 |
# File 'lib/knapsack/tracker.rb', line 8 def initialize set_defaults end |
Instance Attribute Details
#global_time ⇒ Object (readonly)
Returns the value of attribute global_time.
5 6 7 |
# File 'lib/knapsack/tracker.rb', line 5 def global_time @global_time end |
#spec_files_with_time ⇒ Object (readonly)
Returns the value of attribute spec_files_with_time.
5 6 7 |
# File 'lib/knapsack/tracker.rb', line 5 def spec_files_with_time @spec_files_with_time end |
#spec_path ⇒ Object
32 33 34 35 |
# File 'lib/knapsack/tracker.rb', line 32 def spec_path raise("spec_path needs to be set by Knapsack Adapter's bind method") unless @spec_path @spec_path.sub(/^\.\//, '') end |
Instance Method Details
#config(opts = {}) ⇒ Object
12 13 14 15 |
# File 'lib/knapsack/tracker.rb', line 12 def config(opts={}) @config ||= default_config @config.merge!(opts) end |
#exceeded_time ⇒ Object
45 46 47 |
# File 'lib/knapsack/tracker.rb', line 45 def exceeded_time global_time - max_node_time_execution end |
#max_node_time_execution ⇒ Object
41 42 43 |
# File 'lib/knapsack/tracker.rb', line 41 def max_node_time_execution report_distributor.node_time_execution + config[:time_offset_in_seconds] end |
#reset! ⇒ Object
17 18 19 |
# File 'lib/knapsack/tracker.rb', line 17 def reset! set_defaults end |
#start_timer ⇒ Object
21 22 23 |
# File 'lib/knapsack/tracker.rb', line 21 def start_timer @start_time = Time.now.to_f end |
#stop_timer ⇒ Object
25 26 27 28 29 30 |
# File 'lib/knapsack/tracker.rb', line 25 def stop_timer @execution_time = Time.now.to_f - @start_time update_global_time update_spec_file_time @execution_time end |
#time_exceeded? ⇒ Boolean
37 38 39 |
# File 'lib/knapsack/tracker.rb', line 37 def time_exceeded? global_time > max_node_time_execution end |