Method: LabTech::Speedup.compute_factor

Defined in:
app/models/lab_tech/speedup.rb

.compute_factor(baseline, comparison) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/models/lab_tech/speedup.rb', line 12

def self.compute_factor(baseline, comparison)
  # Timing data should never be zero
  return nil if [ baseline, comparison ].any? { |e| e.to_f.zero? }

  time = compute_time_delta(baseline, comparison)
  return nil if time.nil?

  case
  when time > 0   ; +1 * baseline   / comparison
  when time.zero? ;  0
  when time < 0   ; -1 * comparison / baseline
  end
end