Class: Hone::CLI
- Inherits:
-
Thor
- Object
- Thor
- Hone::CLI
- Defined in:
- lib/hone/cli.rb
Overview
Command-line interface for Hone Ruby performance analyzer.
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.exit_on_failure? ⇒ Boolean
34 35 36 |
# File 'lib/hone/cli.rb', line 34 def self.exit_on_failure? true end |
Instance Method Details
#analyze(path) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/hone/cli.rb', line 117 def analyze(path) analyzer = Analyzer.new( path, profile: [:profile], memory_profile: [:memory_profile], format: [:format], color: [:color], quiet: [:quiet], verbose: [:verbose], top: [:top], hot_only: [:hot_only], show_cold: [:show_cold], fail_on: [:fail_on], diff: [:diff], baseline: [:baseline], rails: [:rails] ) result = analyzer.run puts result.output unless result.output.empty? exit result.exit_code end |
#init(component) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/hone/cli.rb', line 157 def init(component) case component when "harness" generator = HarnessGenerator.new(rails: [:rails]) generator.generate else puts "Unknown component: #{component}" puts "Available components: harness" exit 1 end end |
#profile ⇒ Object
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/hone/cli.rb', line 207 def profile unless File.exist?([:harness]) puts "Harness file not found: #{[:harness]}" puts "Run 'hone init harness' to generate a template." exit 1 end profiler_opt = ([:profiler] == "auto") ? nil : [:profiler].to_sym runner = HarnessRunner.new( [:harness], profiler: profiler_opt, memory: [:memory], warmup: [:warmup], output_dir: [:output] ) puts "Loading harness from #{[:harness]}..." puts "Warmup: #{[:warmup]} iterations" puts "Profiler: #{profiler_opt || "auto-detect"}" puts profiles = runner.run puts "Profiles generated:" puts " CPU: #{profiles[:cpu]}" puts " Memory: #{profiles[:memory]}" if profiles[:memory] puts if [:analyze] puts "Running analysis..." invoke :analyze, ["."], profile: profiles[:cpu], memory_profile: profiles[:memory] else puts "Run analysis with:" puts " hone analyze . --profile #{profiles[:cpu]}" end end |