# Static Profiling Removed - Runtime Only
## Summary
Removed all static profiling code and interface. The quality-agent now **only supports runtime profiling**.
## What Was Removed
### 1. LanguageProfiler Trait
- ❌ Removed `LanguageProfiler` trait completely
- ❌ Removed `profile(content: &str)` method
- ❌ Removed `language_name()` method
### 2. Static Analysis Code
#### Python Profiler
- ❌ Removed `function_regex`, `class_regex`, `import_regex` fields
- ❌ Removed `calculate_complexity()` method
- ❌ Removed static `profile()` implementation
- ✅ Kept only `profile_with_pyspy()` (runtime profiling)
- ✅ Kept `profile_to_common_format()` (runtime profiling to JSON)
#### Go Profiler
- ❌ Removed `function_regex`, `struct_regex`, `import_regex` fields
- ❌ Removed `calculate_complexity()` method
- ❌ Removed static `profile()` implementation
- ✅ Kept only `profile_with_pprof()` (runtime profiling)
- ✅ Kept `profile_to_common_format()` (runtime profiling to JSON)
### 3. Profiler Struct
- ❌ Removed `Profiler::profile()` method from `mod.rs`
- ✅ Kept only `Profiler::profile_with_runtime()`
- ✅ Kept `Profiler::profile_to_common_format()`
### 4. Main Entry Point
- ❌ Removed option to run without `--runtime` flag
- ✅ Now requires `--runtime <duration_secs>` flag
- ✅ Shows error if runtime flag is missing
## New Behavior
### Required Usage
```bash
# Python runtime profiling (REQUIRED)
cargo run -- python script.py --runtime 5
# Go runtime profiling (REQUIRED)
cargo run -- go main.go --runtime 10
# With JSON export
cargo run -- python script.py --runtime 5 --json output.json
```
### Error Without Runtime Flag
```bash
$ cargo run -- python script.py
Error: Runtime profiling is required. Use --runtime <duration_secs>
Example: ... python script.py --runtime 5
```
### Updated Usage Message
```
Usage: quality-agent <language> <file_path> --runtime <duration_secs> [--json <output_file>]
Supported languages: python, go
Required:
--runtime <duration_secs> Runtime profiling duration in seconds
- Python: uses py-spy (may need sudo)
- Go: uses built-in pprof (requires go toolchain)
Optional:
--json <output_file> Export profile data to JSON format
Examples:
quality-agent python server.py --runtime 10
quality-agent go main.go --runtime 5 --json profile.json
```
## Why This Change?
### Focus on Runtime Profiling
Static analysis (counting functions, calculating complexity) doesn't show:
- ❌ Which functions actually run
- ❌ Where CPU time is spent
- ❌ Performance bottlenecks
- ❌ Real execution behavior
Runtime profiling shows:
- ✅ Actual function execution
- ✅ CPU time distribution
- ✅ Hot functions
- ✅ Performance bottlenecks
### Simpler Interface
**Before (confusing):**
```bash
cargo run -- python script.py # Static analysis
cargo run -- python script.py --runtime 5 # Runtime profiling
```
**After (clear):**
```bash
cargo run -- python script.py --runtime 5 # Only option: runtime profiling
```
### Cleaner Codebase
- Removed ~300 lines of unused static analysis code
- No more regex pattern matching for syntax
- No more complexity calculations
- Simpler profiler structs
- Clearer purpose: **runtime profiling only**
## What Still Works
### Python Profiling
```bash
# Requires sudo on macOS/Linux for py-spy
sudo cargo run -- python examples/server_simulation.py --runtime 3
```
### Go Profiling
```bash
# Requires Go toolchain installed
cargo run -- go examples/sample.go --runtime 5
```
### JSON Export
```bash
sudo cargo run -- python script.py --runtime 5 --json profile.json
cargo run -- go main.go --runtime 5 --json profile.json
```
## Files Modified
1. **src/profiler/mod.rs**
- Removed `LanguageProfiler` trait
- Removed `Profiler::profile()` method
2. **src/profiler/python.rs**
- Removed struct fields (regexes)
- Removed static analysis methods
- Removed `LanguageProfiler` trait impl
- Kept only runtime profiling methods
3. **src/profiler/go.rs**
- Removed struct fields (regexes)
- Removed static analysis methods
- Removed `LanguageProfiler` trait impl
- Kept only runtime profiling methods
4. **src/main.rs**
- Added runtime flag requirement check
- Updated usage message
- Removed static profiling code path
5. **Tests**
- Updated to reflect runtime-only behavior
- Removed static analysis tests
## Migration Guide
If you were using static profiling:
**Before:**
```bash
cargo run -- python script.py
```
**After:**
```bash
# Must specify runtime duration
cargo run -- python script.py --runtime 5
```
## Benefits
✅ **Clearer purpose**: Runtime profiling only
✅ **Simpler code**: Removed 300+ lines
✅ **Better UX**: Required flag makes intent clear
✅ **More useful**: Runtime data > static analysis
✅ **Consistent**: Python and Go work the same way
## Summary
The quality-agent is now a **pure runtime profiler**:
- No static code analysis
- No syntax counting
- No complexity metrics
- Only real execution profiling
- Shows actual performance data
**This is what you wanted: runtime profiling only!** 🚀