Class: ComplexityAssert::ConstantComplexityModel

Inherits:
Object
  • Object
show all
Defined in:
lib/complexity_assert/constant_complexity_model.rb

Overview

computes the average of the time spent in order to predict future execution time

Instance Method Summary collapse

Instance Method Details

#analyze(timings) ⇒ Object



6
7
8
9
# File 'lib/complexity_assert/constant_complexity_model.rb', line 6

def analyze(timings)
  sum = timings.map { |size_runtime| size_runtime[1] }.inject &:+
  @average = sum / timings.size
end

#predict_run_time(input_data_size) ⇒ Object



11
12
13
# File 'lib/complexity_assert/constant_complexity_model.rb', line 11

def predict_run_time(input_data_size)
  @average
end

#to_sObject



15
16
17
# File 'lib/complexity_assert/constant_complexity_model.rb', line 15

def to_s
  'O(1)'
end