> For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt.

# Performance

本页面介绍 Lynx DevTool 支持的 `Performance` CDP domain。



:::warning 实验性参考
此生成的参考文档仍在完善中。

- CDP events 尚未包含。
- 部分 Lynx 扩展已列出，但尚未提供详细文档。
- 方法说明尚未根据实现自动校验，可能不完整或不准确。

在依赖本参考前，请根据实现及所链接的 upstream CDP reference 验证实际行为。
:::

## 概览

- 作用域：`instance`
- CDP domain：[Performance](https://chromedevtools.github.io/devtools-protocol/tot/Performance/)

## 标准方法

- [Performance.disable](https://chromedevtools.github.io/devtools-protocol/tot/Performance/#method-disable)
- [Performance.enable](https://chromedevtools.github.io/devtools-protocol/tot/Performance/#method-enable)

## Lynx 扩展

### `Performance.getAllPerformanceEntries`

Returns DevTool-recorded Lynx performance entries for the current page.

- Origin: `lynx-extension`
- Source: `devtool/lynx_devtool/agent/domain_agent/inspector_performance_agent.cc`

###### 参数

无参数。

###### 返回字段

| Name                                 | Type      | Description                                                                            |
| ------------------------------------ | --------- | -------------------------------------------------------------------------------------- |
| `entries`                            | `array`   | Performance entry objects recorded by the Lynx performance controller.                 |
| `entries[].entryType`                | `string`  | Entry type. The native DevTool cache currently records pipeline entries.               |
| `entries[].instanceId`               | `integer` | Lynx instance id added by PerformanceController before the entry is cached.            |
| `entries[].name`                     | `string`  | Entry name generated by the timing pipeline, usually derived from the pipeline origin. |
| `entries[].frameworkRenderingTiming` | `object`  | Timing markers supplied by the frontend framework.                                     |
| `entries[].hostPlatformTiming`       | `object`  | Timing markers supplied by the host platform.                                          |

###### 备注

- Dispatches through LynxDevToolMediator to InspectorUIExecutor on the UI thread.
- The executor reads LynxShell::GetAllPerformanceEntries() and wraps the converted array as result.entries.
- PerformanceController only caches pipeline entries when LynxEnv DevTool is enabled. This is independent of the CDP Performance.enable method.
- The method returns an empty entries array when there are no cached entries.
- Cached entries are cleared by PerformanceController::ResetStateBeforeReload().
- The entry object is extensible. Fields beyond entryType, instanceId, name, frameworkRenderingTiming, and hostPlatformTiming are owned by the Timing API and may vary by pipeline type.
- The native implementation does not read request params.
- If the shell has already been destroyed, the current handler sends a response with the request id and no result object.

###### 示例

**Read recorded performance entries**

Request:

```json
{
  "id": 1,
  "method": "Performance.getAllPerformanceEntries"
}
```

Response:

```json
{
  "id": 1,
  "result": {
    "entries": [
      {
        "entryType": "pipeline",
        "instanceId": 1001,
        "name": "loadBundle",
        "frameworkRenderingTiming": {},
        "hostPlatformTiming": {}
      }
    ]
  }
}
```

### `Performance.getAllTimingInfo`

Returns all Lynx timing information for the current page in microseconds.

- Origin: `lynx-extension`
- Source: `devtool/lynx_devtool/agent/domain_agent/inspector_performance_agent.cc`

###### 参数

无参数。

###### 返回字段

| Name                       | Type      | Description                                                            |
| -------------------------- | --------- | ---------------------------------------------------------------------- |
| `setup_timing`             | `object`  | Setup timing map prepared by the timing handler.                       |
| `extra_timing`             | `object`  | Container-layer timing map.                                            |
| `metrics`                  | `object`  | Computed timing metric map.                                            |
| `update_timings`           | `object`  | Map from update timing flag to the corresponding update timing map.    |
| `url`                      | `string`  | Current page URL recorded by TimingInfo.                               |
| `thread_strategy`          | `integer` | Numeric value of the rendering thread strategy recorded by TimingInfo. |
| `has_reload`               | `boolean` | Whether the timing handler has observed a reload for the current page. |
| `ssr_metrics`              | `object`  | SSR timing metric map, present only when SSR timing data is used.      |
| `ssr_render_page_timing`   | `object`  | SSR render page timing map, present only when SSR timing data is used. |
| `ssr_extra_info`           | `object`  | SSR extra info object, present only when SSR timing data is used.      |
| `ssr_extra_info.url`       | `string`  | SSR URL recorded by TimingInfo.                                        |
| `ssr_extra_info.data_size` | `integer` | SSR data size recorded by TimingInfo.                                  |

###### 备注

- Dispatches through LynxDevToolMediator to InspectorUIExecutor on the UI thread.
- The executor reads LynxShell::GetAllTimingInfo() and uses that object directly as the CDP result.
- TimingHandler returns TimingInfo::GetAllTimingInfoAsMicrosecond(), so timestamp and duration values in timing maps are microseconds.
- The nested timing maps are extensible. Their keys are produced by the Timing API and may vary by page lifecycle, pipeline type, platform, and frontend framework markers.
- The native implementation does not read request params and does not require the CDP Performance.enable method.
- If the shell has already been destroyed, the current handler sends a response with the request id and no result object.

###### 示例

**Read all timing info**

Request:

```json
{
  "id": 1,
  "method": "Performance.getAllTimingInfo"
}
```

Response:

```json
{
  "id": 1,
  "result": {
    "setup_timing": {},
    "extra_timing": {},
    "metrics": {},
    "update_timings": {},
    "url": "lynx://example/page",
    "thread_strategy": 0,
    "has_reload": false
  }
}
```

