Skip to main content

profiler

AI Agents Framework PraisonAI Profiler Module Standardized profiling for performance monitoring across praisonai and praisonai-agents. Features:
  • Import timing
  • Function execution timing
  • Flow tracking
  • File/module usage tracking
  • Memory usage (tracemalloc)
  • API call profiling (wall-clock time)
  • Streaming profiling (TTFT, total time)
  • Statistics (p50, p95, p99)
  • cProfile integration
  • Flamegraph generation
  • Line-level profiling
  • JSON/HTML export
Usage:

Import

Classes

TimingRecord

Record of a single timing measurement.

APICallRecord

Record of an API/HTTP call.

StreamingRecord

Record of streaming operation (LLM responses).

MemoryRecord

Record of memory usage.

ImportRecord

Record of a module import.

FlowRecord

Record of execution flow.

StreamingTracker

Track streaming operations (LLM responses).

ProfilerCompat

Compatibility wrapper for old classmethod-based Profiler usage.

ImportProfiler

Context manager to profile imports.

Functions

get_profiler()

Get the current profiler (context-aware or default).

set_profiler()

Set the current profiler in context.

profile()

Decorator to profile a function.

profile_async()

Decorator to profile an async function.

profile_imports()

Create an import profiler context manager.

profile_api()

Decorator to profile a function as an API call.

profile_api_async()

Decorator to profile an async function as an API call.

profile_detailed()

Decorator for detailed cProfile profiling.

profile_lines()

Decorator for line-level profiling.

time_import()

Time how long it takes to import a module.

check_module_available()

Check if a module is available without importing it.

Constants


Agent Profiles

Profiling