> 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.

# AndroidHostPlatformTiming

APISummary
该接口描述了 [Lynx Pipeline](/next/zh/guide/spec.md#lynx-pipeline) 中 Android 平台特有 Measure、Layout 和 Draw 的性能数据，具体如下图所示：

![](https://lf-lynx.tiktok-cdns.com/obj/lynx-artifacts-oss-sg/plugin/static/host-platform-timing.png)
## 示例

该示例展示了如何产生和获取 `PipelineEntry`。

**下面是一个示例: performance-api**

**Entry:** `src/host-platform-timing`
**Bundle:** `dist/host-platform-timing.lynx.bundle`

```tsx {21-21}
import { root, useEffect, useState } from "@lynx-js/react";
import type { PerformanceEntry, PipelineEntry } from "@lynx-js/types";
import { ScrollItem } from "../common/scroll-item/index.jsx";
import "./index.scss";

export default function PipelineEntryExample() {
  const [myName, setMyName] = useState<string | undefined>(undefined);
  const [pipelineEntry, setPipelineEntry] = useState("");
  const [hostPlatformTiming, setHostPlatformTiming] = useState("");

  useEffect(() => {
    "background-only";
    // 1. Create a performance observer.
    const observer = lynx.performance.createObserver((entry: PerformanceEntry) => {
      if (entry.entryType == "pipeline") {
        // 3. Received "pipeline" event of "myPipeline".
        const pipelineEntry = entry as PipelineEntry;
        // `PerformanceEntry.identifier` is equal to `view.__lynx_timing_flag`.
        if (pipelineEntry.identifier == "myNamePipeline") {
          setPipelineEntry(JSON.stringify(pipelineEntry, null, 4));
          setHostPlatformTiming(JSON.stringify(pipelineEntry.hostPlatformTiming, null, 4));
        }
      }
    });
    // 2. Register to listen to the "pipeline" event.
    observer.observe(["pipeline"]);

    // Update real data after simulating a network request.
    setTimeout(() => {
      setMyName("HostPlatformTiming");
    }, 2000);
  }, []);

  return (
    <view className="container">
      <text className="title" __lynx_timing_flag={myName ? "myNamePipeline" : ""}>Hello {myName}~</text>
      <ScrollItem title="HostPlatformTiming" value={hostPlatformTiming} height="220px" />
      <ScrollItem title="PipelineEntry" value={pipelineEntry} />
    </view>
  );
}

root.render(<PipelineEntryExample />);

if (import.meta.webpackHot) {
  import.meta.webpackHot.accept();
}

```

v0.8.0



## 实例属性

### hostPlatformType

```tsx
hostPlatformType: string;
```

描述 Host Platform 类型的字符串，默认取值为：`Android`。

### measureStart

```tsx
measureStart: number;
```

在一次 Lynx Pipeline 中，首次执行 [LynxView](/next/zh/guide/spec.md#lynxview) 的 [onMeasure](https://developer.android.com/reference/android/view/View#onMeasure\(int,%20int\)) 的开始时间戳。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### measureEnd

```tsx
measureEnd: number;
```

在一次 Lynx Pipeline 中，最后一次执行 [LynxView](/next/zh/guide/spec.md#lynxview) 的 [`onMeasure`](https://developer.android.com/reference/android/view/View#onMeasure\(int,%20int\)) 的结束时间戳。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### layoutStart

```tsx
layoutStart: number;
```

在一次 Lynx Pipeline 中，首次执行 [LynxView](/next/zh/guide/spec.md#lynxview) 的 [`onLayout`](https://developer.android.com/reference/android/view/View#onLayout\(boolean,%20int,%20int,%20int,%20int\)) 的开始时间戳。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### layoutEnd

```tsx
layoutEnd: number;
```

在一次 Lynx Pipeline 中，最后一次执行 [LynxView](/next/zh/guide/spec.md#lynxview) 的 [`onLayout`](https://developer.android.com/reference/android/view/View#onLayout\(boolean,%20int,%20int,%20int,%20int\)) 的结束时间戳。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### drawStart

```tsx
drawStart: number;
```

在一次 Lynx Pipeline 中，执行 [LynxView](/next/zh/guide/spec.md#lynxview) 的 [`dispatchDraw`](https://developer.android.com/reference/android/view/View#dispatchDraw\(android.graphics.Canvas\)) 的开始时间戳。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### drawEnd

```tsx
drawEnd: number;
```

在一次 Lynx Pipeline 中，执行 [LynxView](/next/zh/guide/spec.md#lynxview) 的 [`dispatchDraw`](https://developer.android.com/reference/android/view/View#dispatchDraw\(android.graphics.Canvas\)) 的结束时间戳。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

## 兼容性

**Compatibility Table**

**Query:** `lynx-api.performance-api.host-platform-timing.android-host-platform-timing`

[Source](https://github.com/lynx-family/lynx-website/tree/main/packages/lynx-compat-data/lynx-api/performance-api/host-platform-timing/android-host-platform-timing.json)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| android-host-platform-timing | Yes (3.1) | Yes (3.4) | Yes (3.1) | Yes (3.7) | Yes (3.7) | No |

