Performance Benchmarks
Measure import time, memory usage, and lazy-import compliance for PraisonAI Agents
Verify your agent stack meets performance targets — import under 200 ms, heavy deps loaded only when needed.
from praisonaiagents import Agent
# Silent output (default) keeps import overhead minimal
agent = Agent(name="Bench", instructions="You are helpful.")
result = agent.start("Say hello in one word")The user runs a lightweight agent; benchmarks verify import time and lazy-loading stay within targets.
Quick Start
- Simple Usage
Run the built-in benchmark from the CLI:
bash pip install praisonai praisonai perf benchmark - With Configuration
Add a CI gate that fails on agent-instantiation regressions using the built-in benchmark:
yaml # .github/workflows/agent-performance.yml name: agent-performance on: pull_request: paths: - 'src/praisonai-agents/praisonaiagents/**' - 'src/praisonai-agents/benchmarks/**' jobs: benchmark: runs-on: ubuntu-latest timeout-minutes: 5 steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: '3.11' - run: pip install -e src/praisonai-agents - name: Run benchmark with threshold gate working-directory: src/praisonai-agents run: python benchmarks/simple_benchmark.py --skip-crewai --json --fail-over-threshold | tee agent-perf-baseline.json - uses: actions/upload-artifact@v4 with: name: agent-perf-baseline path: src/praisonai-agents/agent-perf-baseline.jsonBudgets live in
src/praisonai-agents/benchmarks/thresholds.json:json { "praisonai_instantiation_us_max": 150, "iterations": 100, "warmup": 10 }
Performance Targets
| Metric | Target | Hard fail | Description |
|---|---|---|---|
| Import time | < 200 ms | > 300 ms | Time to import praisonaiagents |
| Memory usage | < 30 MB | > 45 MB | Memory after import |
| Lazy imports | All lazy | Any eager | Heavy deps not loaded at import |
| Agent instantiation | < 150 µs | > 150 µs | CI regression budget (≈3× the typical ~48 μs), not a typical value. Gated by simple_benchmark.py --fail-over-threshold using thresholds.json. |
How It Works
CLI commands
praisonai perf benchmark # Full suite
praisonai perf import-time # Import time only
praisonai perf memory # Memory usage only
praisonai perf lazy-check # Verify lazy importsPython benchmark scripts
From the SDK repo:
python benchmarks/import_time.py
python benchmarks/memory_usage.pyConfiguration Options
| Option | Type | Default | Description |
|---|---|---|---|
output | str | "silent" | Silent mode avoids loading Rich at import |
| Import gate | CI threshold | 300 ms | Hard fail limit for CI pipelines |
| Lazy modules | sys.modules check | — | litellm, chromadb, mem0, requests |
Typical results (agent instantiation measured 2026-10-15 on Linux x86_64, 4 CPUs, see BENCHMARK_RESULTS.md):
| Metric | Target | Typical |
|---|---|---|
| Import time | < 200 ms | Varies by machine; see CI gate |
| Agent instantiation | < 150 μs (CI gate) | ~46 μs (Oct 2026, praisonaiagents 1.7.12) |
| Memory per agent | < 10 KB | ~4 KB |
| Heavy deps | Lazy | Lazy |
Best Practices
Use silent output in production
output="silent" is the default — zero Rich overhead on the hot path. Keep it for APIs and batch jobs.
Import only what you need
Prefer from praisonaiagents import Agent over star imports to minimise load time.
Gate CI on import time
Add the 300 ms assert to your pipeline so lazy-loading regressions fail early.
Use LiteAgent for minimal footprint
For embedded or high-volume use, from praisonaiagents.lite import LiteAgent reduces memory further.