# tf.profiler.experimental.Profile

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.14.0/tensorflow/python/profiler/profiler_v2.py#L183-L212) |

Context-manager profile API.

    tf.profiler.experimental.Profile(
        logdir, options=None
    )

Profiling will start when entering the scope, and stop and save the results to
the logdir when exits the scope. Open TensorBoard profile tab to view results.

#### Example usage:

    with tf.profiler.experimental.Profile("/path/to/logdir"):
      # do some work

<br />

<br />

<br />

| ## Args ||
|---|---|
| `logdir` | profile data will save to this directory. |
| `options` | An optional [`tf.profiler.experimental.ProfilerOptions`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/profiler/experimental/ProfilerOptions) can be provided to fine tune the profiler's behavior. |

<br />

## Methods

### `__enter__`

[View source](https://github.com/tensorflow/tensorflow/blob/v2.14.0/tensorflow/python/profiler/profiler_v2.py#L208-L209)

    __enter__()

### `__exit__`

[View source](https://github.com/tensorflow/tensorflow/blob/v2.14.0/tensorflow/python/profiler/profiler_v2.py#L211-L212)

    __exit__(
        typ, value, tb
    )