Class: RailsForge::Analyzers::PerformanceAnalyzer
- Inherits:
-
BaseAnalyzer
- Object
- BaseAnalyzer
- RailsForge::Analyzers::PerformanceAnalyzer
- Defined in:
- lib/railsforge/analyzers/performance_analyzer.rb
Overview
PerformanceAnalyzer scans code for performance problems
Constant Summary collapse
- ISSUE_TYPES =
Performance issue types
{ n_plus_one: "N+1 Query", missing_index: "Missing Database Index", slow_method: "Slow Method", inefficient_query: "Inefficient Query", cache_miss: "Cache Miss", eager_loading: "Unnecessary Eager Loading" }.freeze
Class Method Summary collapse
-
.analyze(base_path = nil) ⇒ Array<Hash>
Analyze Rails app for performance issues.
-
.print_report(issues) ⇒ Object
Print performance report.
Instance Method Summary collapse
-
#find_issues ⇒ Array<Hash>
Find all performance issues.
-
#initialize(base_path) ⇒ PerformanceAnalyzer
constructor
Initialize analyzer.
Methods inherited from BaseAnalyzer
#analyze, #find_rails_app_path, find_rails_app_path
Constructor Details
#initialize(base_path) ⇒ PerformanceAnalyzer
Initialize analyzer
32 33 34 35 |
# File 'lib/railsforge/analyzers/performance_analyzer.rb', line 32 def initialize(base_path) @base_path = base_path @issues = [] end |
Class Method Details
.analyze(base_path = nil) ⇒ Array<Hash>
Analyze Rails app for performance issues
23 24 25 26 27 28 |
# File 'lib/railsforge/analyzers/performance_analyzer.rb', line 23 def self.analyze(base_path = nil) base_path ||= find_rails_app_path return [] unless base_path new(base_path).find_issues end |
.print_report(issues) ⇒ Object
Print performance report
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/railsforge/analyzers/performance_analyzer.rb', line 50 def self.print_report(issues) puts "Performance Analysis" puts "=" * 50 if issues.empty? puts "✓ No performance issues found" return end puts "Found #{issues.count} performance issue(s):" puts "" issues.each do |issue| puts "⚠ #{issue[:type]}" puts " File: #{issue[:file]}" puts " Line: #{issue[:line]}" puts " Issue: #{issue[:message]}" puts "" end end |
Instance Method Details
#find_issues ⇒ Array<Hash>
Find all performance issues
39 40 41 42 43 44 45 46 |
# File 'lib/railsforge/analyzers/performance_analyzer.rb', line 39 def find_issues check_n_plus_one check_missing_indexes check_slow_methods check_inefficient_queries @issues end |