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.

python
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.

Diagram

Performance Checks

Import time\n< 200 ms

Memory\n< 30 MB

Lazy imports\nno eager deps

praisonaiagents

Quick Start

  1. Simple Usage

    Run the built-in benchmark from the CLI:

    bash
    pip install praisonai
    praisonai perf benchmark
  2. 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.json

    Budgets live in src/praisonai-agents/benchmarks/thresholds.json:

    json
    {
      "praisonai_instantiation_us_max": 150,
      "iterations": 100,
      "warmup": 10
    }

Performance Targets

MetricTargetHard failDescription
Import time< 200 ms> 300 msTime to import praisonaiagents
Memory usage< 30 MB> 45 MBMemory after import
Lazy importsAll lazyAny eagerHeavy deps not loaded at import
Agent instantiation< 150 µs> 150 µsCI 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

Diagram
Heavy depspraisonaiagentspraisonai perfHeavy depspraisonaiagentspraisonai perflitellm, chromadb, mem0NOT loaded until first useMeasure import timeCheck sys.modulesLazy load on first LLM call

CLI commands

bash
praisonai perf benchmark    # Full suite
praisonai perf import-time  # Import time only
praisonai perf memory       # Memory usage only
praisonai perf lazy-check   # Verify lazy imports

Python benchmark scripts

From the SDK repo:

bash
python benchmarks/import_time.py
python benchmarks/memory_usage.py

Configuration Options

OptionTypeDefaultDescription
outputstr"silent"Silent mode avoids loading Rich at import
Import gateCI threshold300 msHard fail limit for CI pipelines
Lazy modulessys.modules check—litellm, chromadb, mem0, requests

Typical results (agent instantiation measured 2026-10-15 on Linux x86_64, 4 CPUs, see BENCHMARK_RESULTS.md):

MetricTargetTypical
Import time< 200 msVaries 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 depsLazyLazy

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.


Related