# uni.getPerformance

返回一个Performance对象实例

# getPerformance 兼容性

Web 微信小程序 Android iOS HarmonyOS HarmonyOS(Vapor)
x 4.41 3.91 4.25 4.61 x

# 返回值

类型
Performance

# Performance 的方法

# createObserver(callback: PerformanceObserverCallback): PerformanceObserver

createObserver 创建全局性能事件监听器

# createObserver 兼容性
Web 微信小程序
x 4.41
# 参数
名称 类型 必填 默认值 兼容性 描述
callback (entries: PerformanceObserverEntryList) => void
# PerformanceObserverEntryList 的方法
# getEntries(): PerformanceEntry[]

getEntries 该方法返回当前列表中的所有性能数据

# getEntries 兼容性
Web
x
# 返回值
类型
Array<PerformanceEntry>
名称 类型 必备 默认值 兼容性 描述
entryType string
指标类型
name string
指标名称
duration number
耗时 ms。仅对于表示阶段的指标有效。
startTime number
开始时间,不同指标的具体含义会有差异。
path string
页面路径。仅 render 和 navigation 类型指标有效。
referrerPath string
页面跳转来源页面路径。仅 route 指标有效。
pageId number
path 对应页面实例 Id(随机生成,不保证递增)。仅 render/navigation 指标有效。
referrerPageId number
referrerPath对应页面实例 Id(随机生成,不保证递增)。仅 route 指标有效。
navigationStart number
路由真正响应开始时间。仅 navigation 类型指标有效。
navigationType string
路由详细类型,与路由方法对应。仅 navigation 类型指标有效。
initDataRecvTime number
首次渲染参数在渲染层收到的时间。仅 firstRender 指标有效。
viewLayerRenderEndTime number
渲染层执行渲染结束时间。仅 firstRender 指标有效。
# getEntriesByType(entryType: string): PerformanceEntry[]

getEntriesByType 获取当前列表中所有类型为 [entryType]的性能数据

# getEntriesByType 兼容性
Web
x
# 参数
名称 类型 必填 默认值 兼容性 描述
entryType string
# 返回值
类型
Array<PerformanceEntry>
# getEntriesByName(name: string, entryType: string): PerformanceEntry[]

getEntriesByName 获取当前列表中所有名称为 [name] 且类型为 [entryType]的性能数据

# getEntriesByName 兼容性
Web
x
# 参数
名称 类型 必填 默认值 兼容性 描述
name string
entryType string
# 返回值
类型
Array<PerformanceEntry>
# 返回值
类型
PerformanceObserver
# PerformanceObserver 的方法
# observe(options: PerformanceObserverOptions): void

observe 开始监听

# observe 兼容性
Web
x
# 参数
名称 类型 必填 默认值 兼容性 描述
options PerformanceObserverOptions
名称 类型 必备 默认值 兼容性 描述
buffered boolean
entryTypes Array<string>
type string
# disconnect(): void

disconnect 停止监听

# disconnect 兼容性
Web
x

# getEntries(): PerformanceEntry[]

getEntries 该方法返回当前缓冲区中的所有性能数据

# getEntries 兼容性
Web 微信小程序
x 4.41
# 返回值
类型
Array<PerformanceEntry>

# getEntriesByType(entryType: string): PerformanceEntry[]

getEntriesByType 获取当前缓冲区中所有类型为 [entryType]的性能数据

# getEntriesByType 兼容性
Web 微信小程序
x 4.41
# 参数
名称 类型 必填 默认值 兼容性 描述
entryType string
# 返回值
类型
Array<PerformanceEntry>

# getEntriesByName(name: string, entryType: string): PerformanceEntry[]

getEntriesByName 获取当前缓冲区中所有名称为 [name] 且类型为 [entryType]的性能数据

# getEntriesByName 兼容性
Web 微信小程序
x 4.41
# 参数
名称 类型 必填 默认值 兼容性 描述
name string
entryType string
# 返回值
类型
Array<PerformanceEntry>

# setBufferSize(size: number): void

setBufferSize 设置缓冲区大小,默认缓冲 30 条性能数据

# setBufferSize 兼容性
Web 微信小程序
x 4.41
# 参数
名称 类型 必填 默认值 兼容性 描述
size number

# 参见

# 通用类型

# GeneralCallbackResult

名称 类型 必备 默认值 兼容性 描述
errMsg string
错误信息