# ProfilingSnapshot

> Canonical profiling snapshot holding the request metrics, the resolved profile blocks, and the memory samples that feed the timeline chart.

[API reference](/docs/api/index.md) › [Debug Core](/docs/extensions/debug-core/reference/index.md) › [Panel](/docs/extensions/debug-core/reference/panel/index.md) › [Profile](/docs/extensions/debug-core/reference/panel/profile/index.md) › ProfilingSnapshot

| final readonly class | `PHPForge\Debug\Panel\Profile\ProfilingSnapshot` |
| --- | --- |
| Implements | [`PHPForge\Debug\Storage\PanelSnapshot`](/docs/extensions/debug-core/reference/storage/panelsnapshot/index.md) |
| Source | [`src/Panel/Profile/ProfilingSnapshot.php`](https://github.com/php-forge/debug-core/blob/main/src/Panel/Profile/ProfilingSnapshot.php#L23) |

Canonical profiling snapshot holding the request metrics, the resolved profile blocks, and the memory samples that
feed the timeline chart.

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-memory"></span>`$memory` readonly constructor | `int` | Peak memory in bytes recorded for the request. | `ProfilingSnapshot` |
| <span id="property-time"></span>`$time` readonly constructor | `float` | Request processing duration in seconds. | `ProfilingSnapshot` |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Creates a profiling snapshot from request metrics, blocks, and memory samples. | `ProfilingSnapshot` |
| [`capture()`](#method-capture) static | Resolves the logger's begin/end pairs into typed blocks and collects the per-message memory samples. | `ProfilingSnapshot` |
| [`captureCompleted()`](#method-captureCompleted) static | Normalizes completed profiler messages carrying token, category, timing, nesting, memory, and trace context. | `ProfilingSnapshot` |
| [`entries()`](#method-entries) | Returns the resolved profile blocks. | `ProfilingSnapshot` |
| [`fromArray()`](#method-fromArray) static | Narrows the persisted profiling payload into a typed snapshot. | `ProfilingSnapshot` |
| [`jsonSerialize()`](#method-jsonSerialize) | Returns the panel snapshot for JSON serialization. | `ProfilingSnapshot` |
| [`samples()`](#method-samples) | Returns the memory samples that feed the timeline chart. | `ProfilingSnapshot` |

## Method details

### __construct() <span id="method-__construct"></span>

```php
public function __construct(int $memory, float $time, list<PHPForge\Debug\Panel\Profile\ProfileRow> $entries, list<PHPForge\Debug\Panel\MemorySample> $samples)
```

Creates a profiling snapshot from request metrics, blocks, and memory samples.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$memory` | `int` |  |
| `$time` | `float` |  |
| `$entries` | `list<`[`ProfileRow`](/docs/extensions/debug-core/reference/panel/profile/profilerow/index.md)`>` |  |
| `$samples` | `list<`[`PHPForge\Debug\Panel\MemorySample`](/docs/extensions/debug-core/reference/panel/memorysample/index.md)`>` |  |

### capture() <span id="method-capture"></span>

```php
public static function capture(int $memory, float $time, list<PHPForge\Debug\Panel\Profile\LogTuple> $messages): self
```

Resolves the logger's begin/end pairs into typed blocks and collects the per-message memory samples.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$memory` | `int` |  |
| `$time` | `float` |  |
| `$messages` | `list<PHPForge\Debug\Panel\Profile\LogTuple>` | Profile tuples in capture order. |

**Returns**

`self`

### captureCompleted() <span id="method-captureCompleted"></span>

```php
public static function captureCompleted(int $memory, float $time, array<int|string, mixed> $messages): self
```

Normalizes completed profiler messages carrying token, category, timing, nesting, memory, and trace context.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$memory` | `int` |  |
| `$time` | `float` |  |
| `$messages` | `array<int\|string, mixed>` | Completed profiler messages. |

**Returns**

`self`

### entries() <span id="method-entries"></span>

```php
public function entries(): list<PHPForge\Debug\Panel\Profile\ProfileRow>
```

Returns the resolved profile blocks.

**Returns**

`list<`[`ProfileRow`](/docs/extensions/debug-core/reference/panel/profile/profilerow/index.md)`>`: Resolved profile blocks in capture order.

### fromArray() <span id="method-fromArray"></span>

```php
public static function fromArray(mixed $data, string $path): self
```

Narrows the persisted profiling payload into a typed snapshot.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$data` | `mixed` | Persisted payload, expected to be an object carrying the declared shape. |
| `$path` | `string` | JSON path of the payload, used to report a malformed capture. |

**Returns**

`self`: Snapshot carrying the request metrics, the profile blocks, and the memory samples.

### jsonSerialize() <span id="method-jsonSerialize"></span>

```php
public function jsonSerialize(): array<string, mixed>
```

Returns the panel snapshot for JSON serialization.

**Returns**

`array<string, mixed>`

### samples() <span id="method-samples"></span>

```php
public function samples(): list<PHPForge\Debug\Panel\MemorySample>
```

Returns the memory samples that feed the timeline chart.

**Returns**

`list<`[`PHPForge\Debug\Panel\MemorySample`](/docs/extensions/debug-core/reference/panel/memorysample/index.md)`>`: Memory readings recorded alongside each captured profile message.