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.
-
#test_files_with_time ⇒ Object
readonly
Returns the value of attribute test_files_with_time.
- #test_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 |
#test_files_with_time ⇒ Object (readonly)
Returns the value of attribute test_files_with_time.
5 6 7 |
# File 'lib/knapsack/tracker.rb', line 5 def test_files_with_time @test_files_with_time end |
#test_path ⇒ Object
37 38 39 |
# File 'lib/knapsack/tracker.rb', line 37 def test_path @test_path.sub(/^\.\//, '') if @test_path 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
49 50 51 |
# File 'lib/knapsack/tracker.rb', line 49 def exceeded_time global_time - max_node_time_execution end |
#max_node_time_execution ⇒ Object
45 46 47 |
# File 'lib/knapsack/tracker.rb', line 45 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 = now_without_mock_time.to_f end |
#stop_timer ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/knapsack/tracker.rb', line 25 def stop_timer execution_time = now_without_mock_time.to_f - @start_time if test_path update_global_time(execution_time) update_test_file_time(execution_time) @test_path = nil end execution_time end |
#time_exceeded? ⇒ Boolean
41 42 43 |
# File 'lib/knapsack/tracker.rb', line 41 def time_exceeded? global_time > max_node_time_execution end |