---
title: SimpleProfiler
description: >-
  This profiler simply records the duration of actions (in seconds) and reports
  the mean duration of each action

  and the total time spent over the entire training run.
canonical: >-
  https://lightning.ai/docs/pytorch/stable/optional-api/api/lightning.pytorch.profilers.SimpleProfiler
---
# SimpleProfiler {#simpleprofiler}

### `class lightning.pytorch.profilers.SimpleProfiler(dirpath=None, filename=None, extended=True)` {#lightning.pytorch.profilers.SimpleProfiler}

Bases: [`Profiler`](/docs/pytorch/2.6.6/optional-api/api/lightning.pytorch.profilers.Profiler.md#lightning.pytorch.profilers.Profiler "lightning.pytorch.profilers.profiler.Profiler")

This profiler simply records the duration of actions (in seconds) and reports the mean duration of each action and the total time spent over the entire training run.

Parameters:

*   **dirpath** (`Union`\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"), [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path "(in Python v3.15)"), [`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")\]) – Directory path for the `filename`. If `dirpath` is `None` but `filename` is present, the `trainer.log_dir` (from [`TensorBoardLogger`](/docs/pytorch/2.6.6/optional-api/api/lightning.pytorch.loggers.tensorboard.md#lightning.pytorch.loggers.tensorboard.TensorBoardLogger "lightning.pytorch.loggers.tensorboard.TensorBoardLogger")) will be used.
    
*   **filename** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")\]) – If present, filename where the profiler results will be saved instead of printing to stdout. The `.txt` extension will be used automatically.
    
*   **extended** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")) – If `True`, adds extra columns representing number of calls and percentage of total time spent on respective action.
    

Raises:

[**ValueError**](https://docs.python.org/3/builtins/exceptions.html#ValueError "(in Python v3.15)") – If you attempt to start an action which has already started, or if you attempt to stop recording an action which was never started.

#### `start(action_name)` {#lightning.pytorch.profilers.SimpleProfiler.start}

Defines how to start recording an action.

Return type:

[`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")

#### `stop(action_name)` {#lightning.pytorch.profilers.SimpleProfiler.stop}

Defines how to record the duration once an action is complete.

Return type:

[`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")

---

**Navigation**

- Parent: [Api](/docs/pytorch/2.6.6/optional-api/api.md)
