Skip to main content

praisonai.profiler

Wrapper 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: from praisonai.profiler import Profiler, profile, profile_imports

Profile a function

@profile def my_function(): pass

Profile a block

with Profiler.block(“my_operation”): do_something()

Profile API calls

with Profiler.api_call(“https://api.example.com”) as call: response = requests.get(…)

Profile streaming

with Profiler.streaming(“chat”) as tracker: tracker.first_token() for chunk in stream: tracker.chunk()

Profile imports

with profile_imports(): import heavy_module

Get report with statistics

Profiler.report() stats = Profiler.get_statistics()

Export

Profiler.export_json() Profiler.export_html()

Overview

This module provides components for profiler.

Classes

Functions