Class: Testprune::SavingsEstimator
- Inherits:
-
Object
- Object
- Testprune::SavingsEstimator
- Defined in:
- lib/testprune/savings_estimator.rb
Overview
Estimates CI time recovered by removing the approved candidates. Reports aggregate test time removed — honest about the fact that parallel runners mean wall-clock savings are smaller.
Instance Method Summary collapse
- #approved_count ⇒ Object
- #approved_time ⇒ Object
-
#initialize(run, detector_result) ⇒ SavingsEstimator
constructor
A new instance of SavingsEstimator.
- #percent_of_test_time ⇒ Object
- #total_test_time ⇒ Object
Constructor Details
#initialize(run, detector_result) ⇒ SavingsEstimator
Returns a new instance of SavingsEstimator.
8 9 10 11 |
# File 'lib/testprune/savings_estimator.rb', line 8 def initialize(run, detector_result) @run = run @detector = detector_result end |
Instance Method Details
#approved_count ⇒ Object
13 14 15 |
# File 'lib/testprune/savings_estimator.rb', line 13 def approved_count @detector.approved_removals.size end |
#approved_time ⇒ Object
17 18 19 |
# File 'lib/testprune/savings_estimator.rb', line 17 def approved_time @detector.approved_removals.sum { |c| c.footprint.wall_time || 0.0 } end |
#percent_of_test_time ⇒ Object
25 26 27 28 |
# File 'lib/testprune/savings_estimator.rb', line 25 def percent_of_test_time base = total_test_time base.zero? ? 0.0 : (approved_time / base * 100) end |
#total_test_time ⇒ Object
21 22 23 |
# File 'lib/testprune/savings_estimator.rb', line 21 def total_test_time (@run['tests'] || []).sum { |t| t['wall_time'] || 0.0 } end |