Class: Testprune::SavingsEstimator

Inherits:
Object
  • Object
show all
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

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_countObject



13
14
15
# File 'lib/testprune/savings_estimator.rb', line 13

def approved_count
  @detector.approved_removals.size
end

#approved_timeObject



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_timeObject



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_timeObject



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