Class: ComplexityAssert::LinearComplexityModel
- Inherits:
-
Object
- Object
- ComplexityAssert::LinearComplexityModel
- Defined in:
- lib/complexity_assert/linear_complexity_model.rb
Overview
Generates a sample of execution timings to run a linear regression in order to predict another execution time
Instance Method Summary collapse
Instance Method Details
#analyze(timings) ⇒ Object
5 6 7 8 9 |
# File 'lib/complexity_assert/linear_complexity_model.rb', line 5 def analyze(timings) linear_model = SimpleLinearRegression.new(*timings.transpose) @slope = linear_model.slope @y_intercept = linear_model.y_intercept end |
#predict_run_time(input_data_size) ⇒ Object
11 12 13 |
# File 'lib/complexity_assert/linear_complexity_model.rb', line 11 def predict_run_time(input_data_size) @y_intercept + @slope * input_data_size end |
#to_s ⇒ Object
15 16 17 |
# File 'lib/complexity_assert/linear_complexity_model.rb', line 15 def to_s "O(n)" end |