---
title: "ClikaRT::ProfileSession"
sidebar_label: "ProfileSession"
description: "A profiling session: start one or more captures, then export the results. Move-only."
---

<!-- Generated by tools/doxygen2mdx from Doxygen XML. Do not edit. -->

<span class="api-kind api-kind--class">class</span>

**Header:** `ClikaRT/profiler/profiler.h`

A profiling session: start one or more captures, then export the results. Move-only. The session must outlive any in-flight async work it captured (workers that finish after a capture ends still record into it).

## Nested types

| Name | Description |
| --- | --- |
| [`CaptureScope`](./ProfileSession.CaptureScope.md) | RAII capture handle. While alive, work on the constructing thread (and its live streams) is profiled into the parent session. End the capture by letting this go out of scope. Move-only; keep it alive for the region you want timed. |

## Member functions

### ProfileSession() {#ProfileSession}

<div class="api-signature">

**`ProfileSession`**()

</div>

An empty session.

<div class="api-declared">

Declared in `ClikaRT/profiler/profiler.h`, line 124

</div>

### ProfileSession(ProfileSession) {#ProfileSession-2}

<div class="api-signature">

**`ProfileSession`**(`ProfileSession&&`) `noexcept`

</div>

Move-only: transfers the session.

<div class="api-declared">

Declared in `ClikaRT/profiler/profiler.h`, line 126

</div>

### operator=() {#operator-assign}

<div class="api-signature">

[`ProfileSession`](./ProfileSession.md)`&` **`operator=`**([`ProfileSession`](./ProfileSession.md)`&&`) `noexcept`

</div>

Move-assign: transfers the session.

<div class="api-declared">

Declared in `ClikaRT/profiler/profiler.h`, line 128

</div>

### \~ProfileSession() {#ProfileSession-3}

<div class="api-signature">

**`~ProfileSession`**()

</div>

Releases the session and its recorded data.

<div class="api-declared">

Declared in `ClikaRT/profiler/profiler.h`, line 130

</div>

### start\_capture() {#start_capture}

<div class="api-signature">

[`CaptureScope`](./ProfileSession.CaptureScope.md) **`start_capture`**(`std::string_view` `tag` `=` `"default"`)

</div>

Begin a capture region. `tag` names it in the trace. Equivalent to keeping the returned handle alive for the region you want profiled.

<div class="api-declared">

Declared in `ClikaRT/profiler/profiler.h`, line 157

</div>

### save() {#save}

<div class="api-signature">

`void` **`save`**(`std::string_view` `dir`) `const`

</div>

Write the standard set into `dir` (created if missing): `chrome_trace.json`, `report.json`, `memory_stats.json`, `summary.txt`. Raises [`ClikaRT::Error`](./Error.md) on failure.

<div class="api-declared">

Declared in `ClikaRT/profiler/profiler.h`, line 162

</div>

### save\_chrome\_trace() {#save_chrome_trace}

<div class="api-signature">

`void` **`save_chrome_trace`**(`std::string_view` `path`) `const`

</div>

Write just the Chrome-tracing timeline JSON to `path`.

<div class="api-declared">

Declared in `ClikaRT/profiler/profiler.h`, line 165

</div>

### save\_report\_json() {#save_report_json}

<div class="api-signature">

`void` **`save_report_json`**(`std::string_view` `path`) `const`

</div>

Write the full report JSON to `path`.

<div class="api-declared">

Declared in `ClikaRT/profiler/profiler.h`, line 168

</div>

### save\_memory\_stats() {#save_memory_stats}

<div class="api-signature">

`void` **`save_memory_stats`**(`std::string_view` `path`) `const`

</div>

Write the memory-stats JSON to `path`.

<div class="api-declared">

Declared in `ClikaRT/profiler/profiler.h`, line 171

</div>

### chrome\_trace\_json() {#chrome_trace_json}

<div class="api-signature">

`std::string` **`chrome_trace_json`**() `const`

</div>

Snapshot the current results as a Chrome-tracing JSON string. Each snapshot below builds its whole result in memory and fails with `RESOURCE_EXHAUSTED` when that memory runs out; an empty session exports cleanly.

<div class="api-declared">

Declared in `ClikaRT/profiler/profiler.h`, line 178

</div>

### summary\_text() {#summary_text}

<div class="api-signature">

`std::string` **`summary_text`**() `const`

</div>

Snapshot the current results as a human-readable per-op summary.

<div class="api-declared">

Declared in `ClikaRT/profiler/profiler.h`, line 181

</div>

### summary() {#summary}

<div class="api-signature">

[`ProfileSummary`](./ProfileSummary.md) **`summary`**() `const`

</div>

Snapshot the current results as plain counters: the typed form of [`summary_text()`](./ProfileSession.md#summary_text) (see [`ProfileSummary`](./ProfileSummary.md)). An empty session reads as zeros.

<div class="api-declared">

Declared in `ClikaRT/profiler/profiler.h`, line 186

</div>

### perfetto\_trace() {#perfetto_trace}

<div class="api-signature">

`std::string` **`perfetto_trace`**() `const`

</div>

Snapshot the current results as a Perfetto protobuf trace (raw bytes).

<div class="api-declared">

Declared in `ClikaRT/profiler/profiler.h`, line 189

</div>
