Class: Omnizip::Models::OptimizationSuggestion
- Inherits:
-
Object
- Object
- Omnizip::Models::OptimizationSuggestion
- Defined in:
- lib/omnizip/models/optimization_suggestion.rb
Overview
Represents a performance optimization suggestion based on profiling data
Constant Summary collapse
- SEVERITY_LEVELS =
%i[low medium high critical].freeze
- CATEGORIES =
%i[ memory cpu hotpath algorithm io gc allocation concurrency ].freeze
Instance Attribute Summary collapse
-
#category ⇒ Object
readonly
Returns the value of attribute category.
-
#code_locations ⇒ Object
readonly
Returns the value of attribute code_locations.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#impact_estimate ⇒ Object
readonly
Returns the value of attribute impact_estimate.
-
#implementation_effort ⇒ Object
readonly
Returns the value of attribute implementation_effort.
-
#metrics ⇒ Object
readonly
Returns the value of attribute metrics.
-
#related_operations ⇒ Object
readonly
Returns the value of attribute related_operations.
-
#severity ⇒ Object
readonly
Returns the value of attribute severity.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #critical? ⇒ Boolean
- #high_priority? ⇒ Boolean
-
#initialize(title:, description:, severity:, category:, impact_estimate: nil, implementation_effort: nil, related_operations: [], code_locations: [], metrics: {}) ⇒ OptimizationSuggestion
constructor
A new instance of OptimizationSuggestion.
- #priority_score ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(title:, description:, severity:, category:, impact_estimate: nil, implementation_effort: nil, related_operations: [], code_locations: [], metrics: {}) ⇒ OptimizationSuggestion
Returns a new instance of OptimizationSuggestion.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/omnizip/models/optimization_suggestion.rb', line 16 def initialize( title:, description:, severity:, category:, impact_estimate: nil, implementation_effort: nil, related_operations: [], code_locations: [], metrics: {} ) validate_severity!(severity) validate_category!(category) @title = title @description = description @severity = severity @category = category @impact_estimate = impact_estimate @implementation_effort = implementation_effort @related_operations = @code_locations = code_locations @metrics = metrics end |
Instance Attribute Details
#category ⇒ Object (readonly)
Returns the value of attribute category.
12 13 14 |
# File 'lib/omnizip/models/optimization_suggestion.rb', line 12 def category @category end |
#code_locations ⇒ Object (readonly)
Returns the value of attribute code_locations.
12 13 14 |
# File 'lib/omnizip/models/optimization_suggestion.rb', line 12 def code_locations @code_locations end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
12 13 14 |
# File 'lib/omnizip/models/optimization_suggestion.rb', line 12 def description @description end |
#impact_estimate ⇒ Object (readonly)
Returns the value of attribute impact_estimate.
12 13 14 |
# File 'lib/omnizip/models/optimization_suggestion.rb', line 12 def impact_estimate @impact_estimate end |
#implementation_effort ⇒ Object (readonly)
Returns the value of attribute implementation_effort.
12 13 14 |
# File 'lib/omnizip/models/optimization_suggestion.rb', line 12 def implementation_effort @implementation_effort end |
#metrics ⇒ Object (readonly)
Returns the value of attribute metrics.
12 13 14 |
# File 'lib/omnizip/models/optimization_suggestion.rb', line 12 def metrics @metrics end |
#related_operations ⇒ Object (readonly)
Returns the value of attribute related_operations.
12 13 14 |
# File 'lib/omnizip/models/optimization_suggestion.rb', line 12 def @related_operations end |
#severity ⇒ Object (readonly)
Returns the value of attribute severity.
12 13 14 |
# File 'lib/omnizip/models/optimization_suggestion.rb', line 12 def severity @severity end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
12 13 14 |
# File 'lib/omnizip/models/optimization_suggestion.rb', line 12 def title @title end |
Instance Method Details
#critical? ⇒ Boolean
41 42 43 |
# File 'lib/omnizip/models/optimization_suggestion.rb', line 41 def critical? severity == :critical end |
#high_priority? ⇒ Boolean
45 46 47 |
# File 'lib/omnizip/models/optimization_suggestion.rb', line 45 def high_priority? severity == :high || critical? end |
#priority_score ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/omnizip/models/optimization_suggestion.rb', line 49 def priority_score severity_weight = SEVERITY_LEVELS.index(severity) + 1 impact_weight = impact_estimate || 1.0 effort_weight = implementation_effort ? (1.0 / implementation_effort) : 1.0 severity_weight * impact_weight * effort_weight end |
#to_h ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/omnizip/models/optimization_suggestion.rb', line 57 def to_h { title: title, description: description, severity: severity, category: category, impact_estimate: impact_estimate, implementation_effort: implementation_effort, priority_score: priority_score, related_operations: , code_locations: code_locations, metrics: metrics, } end |