How It Works
Quick Start
How It Works
Profiling is off by default — decorators and context managers are no-ops until you callProfiler.enable() or set PRAISONAI_PROFILE=1.
| Surface | Purpose |
|---|---|
@profile / @profile_async | Time a function |
Profiler.block("name") | Time a code block |
Profiler.api_call(...) | Track HTTP/API latency |
Profiler.streaming(...) | Measure TTFT and chunk timing |
Profiler.memory("name") | Track memory with tracemalloc |
Profiler.report() | Console summary with p50/p95/p99 |
deque — when full, oldest records drop. See Performance Profiling for per-agent isolation via set_profiler().
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
PRAISONAI_PROFILE | env int | 0 | Set to 1 to enable globally |
PRAISONAI_PROFILE_MAX | env int | 10000 | Max records per buffer before rotation |
Best Practices
Disable in production by default
Disable in production by default
Enable only when debugging — overhead is near zero when off, but reports and tracemalloc add cost when on.
Size buffers for your RAM budget
Size buffers for your RAM budget
Default 10k records ≈ 1–2 MB per buffer. Lower
PRAISONAI_PROFILE_MAX in containers.Export periodically on long runs
Export periodically on long runs
Ring buffers keep recent data only — export JSON/HTML before buffers rotate.
Use descriptive block names
Use descriptive block names
Profiler.block("llm_call") and Profiler.block("tool_execution") make reports readable.Related
Performance Profiling
Per-agent profiler isolation for multi-agent runs
Observability Overview
Traces, metrics, and logging

