Skip to main content
PraisonAI provides CLI commands for profiling agent performance without modifying code.

Quick Start

Inline Profiling (—profile flag)

The simplest way to profile any command is with the --profile flag:
This outputs a visual timeline diagram showing execution phases:

Deep Profiling

For detailed function-level analysis with call graphs:
This adds:
  • Decision Trace: Agent config, model, streaming mode, tools
  • Top Functions: Cumulative time by function
  • Module Breakdown: Time grouped by module category
  • Call Graph: Caller/callee relationships

JSON Output

Get machine-readable profile data:
The JSON output includes the timeline diagram as a string field for easy parsing.

Commands

profile query

Profile a query execution with detailed timing breakdown:
Options: Examples:
Output:

profile imports

Profile module import times to identify slow imports:
Output:

profile startup

Profile CLI startup time (cold and warm):
Output:

profile suite

Run a comprehensive profiling suite with multiple scenarios:
Options: Examples:
Output:
Output Files:
  • suite_results.json - Machine-readable JSON with all timing data
  • suite_report.txt - Human-readable summary report

Advanced Usage

Deep Call Tracing

Enable deep call tracing for detailed call graph analysis:
Deep call tracing adds significant overhead. Use only for detailed debugging.

Save Artifacts

Save profiling artifacts for later analysis:
This creates:
  • profile_results.prof - Binary cProfile data (can be loaded with pstats)
  • profile_results.txt - Human-readable report

JSON Output

Get machine-readable output for CI/CD integration:

Streaming with First Token Tracking

Track time to first token in streaming mode:

Combine with py-spy

For production-grade flamegraphs:

CI/CD Integration

Add profiling to your CI pipeline:

Output Formats

Text Output (Default)

Human-readable format printed to terminal with timing breakdown, function stats, and response preview.

JSON Output

Machine-readable format for processing:

Best Practices

The suite command runs multiple scenarios with warmup:
Run benchmarks with similar data sizes and network conditions as production.
Group timing by file to find which modules are slowest:
Streaming often has faster time-to-first-token:

Troubleshooting

Import times are dominated by OpenAI SDK. This is expected:
Consider lazy imports if startup time is critical.
Increase iterations in suite mode:
Deep tracing adds significant overhead. Use only for debugging: