> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Profiler • AI Agents Framework

> Profiler: Centralized profiler for performance monitoring.

# Profiler

> Defined in the [**profiler**](../modules/profiler) module.

<Badge color="purple">AI Agents Framework</Badge>

Centralized profiler for performance monitoring.

Thread-safe singleton pattern for global access.

Features:

* Function/block timing
* API call profiling (wall-clock)
* Streaming profiling (TTFT)
* Memory profiling
* Import timing
* Statistics (p50, p95, p99)
* cProfile integration
* Export (JSON, HTML)

## Methods

<CardGroup cols={2}>
  <Card title="enable()" icon="function" href="../functions/Profiler-enable">
    Enable profiling.
  </Card>

  <Card title="disable()" icon="function" href="../functions/Profiler-disable">
    Disable profiling.
  </Card>

  <Card title="is_enabled()" icon="function" href="../functions/Profiler-is_enabled">
    Check if profiling is enabled.
  </Card>

  <Card title="clear()" icon="function" href="../functions/Profiler-clear">
    Clear all profiling data.
  </Card>

  <Card title="record_timing()" icon="function" href="../functions/Profiler-record_timing">
    Record a timing measurement.
  </Card>

  <Card title="record_import()" icon="function" href="../functions/Profiler-record_import">
    Record an import timing.
  </Card>

  <Card title="record_flow()" icon="function" href="../functions/Profiler-record_flow">
    Record a flow step.
  </Card>

  <Card title="block()" icon="function" href="../functions/Profiler-block">
    Context manager for profiling a block of code.
  </Card>

  <Card title="get_timings()" icon="function" href="../functions/Profiler-get_timings">
    Get timing records, optionally filtered by category.
  </Card>

  <Card title="get_imports()" icon="function" href="../functions/Profiler-get_imports">
    Get import records, optionally filtered by minimum duration.
  </Card>

  <Card title="get_flow()" icon="function" href="../functions/Profiler-get_flow">
    Get flow records.
  </Card>

  <Card title="get_files_accessed()" icon="function" href="../functions/Profiler-get_files_accessed">
    Get files accessed with counts.
  </Card>

  <Card title="get_summary()" icon="function" href="../functions/Profiler-get_summary">
    Get profiling summary.
  </Card>

  <Card title="report()" icon="function" href="../functions/Profiler-report">
    Generate and output profiling report.
  </Card>

  <Card title="record_api_call()" icon="function" href="../functions/Profiler-record_api_call">
    Record an API/HTTP call timing.
  </Card>

  <Card title="get_api_calls()" icon="function" href="../functions/Profiler-get_api_calls">
    Get API call records.
  </Card>

  <Card title="api_call()" icon="function" href="../functions/Profiler-api_call">
    Context manager for profiling API calls.
  </Card>

  <Card title="record_streaming()" icon="function" href="../functions/Profiler-record_streaming">
    Record streaming metrics.
  </Card>

  <Card title="get_streaming_records()" icon="function" href="../functions/Profiler-get_streaming_records">
    Get streaming records.
  </Card>

  <Card title="streaming()" icon="function" href="../functions/Profiler-streaming">
    Context manager for profiling streaming operations.
  </Card>

  <Card title="streaming_async()" icon="function" href="../functions/Profiler-streaming_async">
    Async context manager for profiling streaming operations.
  </Card>

  <Card title="record_memory()" icon="function" href="../functions/Profiler-record_memory">
    Record memory usage.
  </Card>

  <Card title="get_memory_records()" icon="function" href="../functions/Profiler-get_memory_records">
    Get memory records.
  </Card>

  <Card title="memory()" icon="function" href="../functions/Profiler-memory">
    Context manager for profiling memory usage.
  </Card>

  <Card title="memory_snapshot()" icon="function" href="../functions/Profiler-memory_snapshot">
    Take a memory snapshot.
  </Card>

  <Card title="get_statistics()" icon="function" href="../functions/Profiler-get_statistics">
    Get statistical analysis of timing data.
  </Card>

  <Card title="cprofile()" icon="function" href="../functions/Profiler-cprofile">
    Context manager for cProfile profiling.
  </Card>

  <Card title="get_cprofile_stats()" icon="function" href="../functions/Profiler-get_cprofile_stats">
    Get cProfile statistics.
  </Card>

  <Card title="get_line_profile_data()" icon="function" href="../functions/Profiler-get_line_profile_data">
    Get line-level profiling data.
  </Card>

  <Card title="set_line_profile_data()" icon="function" href="../functions/Profiler-set_line_profile_data">
    Store line-level profiling data.
  </Card>

  <Card title="get_flamegraph_data()" icon="function" href="../functions/Profiler-get_flamegraph_data">
    Generate flamegraph-compatible data from flow records.
  </Card>

  <Card title="export_flamegraph()" icon="function" href="../functions/Profiler-export_flamegraph">
    Export flamegraph to SVG file.
  </Card>

  <Card title="export_json()" icon="function" href="../functions/Profiler-export_json">
    Export profiling data as JSON.
  </Card>

  <Card title="export_html()" icon="function" href="../functions/Profiler-export_html">
    Export profiling data as HTML report.
  </Card>

  <Card title="export_to_file()" icon="function" href="../functions/Profiler-export_to_file">
    Export profiling data to file.
  </Card>
</CardGroup>

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai/praisonai/profiler.py#L216">
  `praisonai/profiler.py` at line 216
</Card>

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Agent Profiles" icon="id-card" href="/docs/features/agent-profiles" />

  <Card title="Profiling" icon="chart-line" href="/docs/features/profiling" />
</CardGroup>
