title: Performance

sidebar_label: Performance

Performance 对象,用于获取性能数据及创建性能监听器

支持情况:Performance - 图1 Performance - 图2 Performance - 图3

参考文档

方法

createObserver

创建全局性能事件监听器

支持情况:Performance - 图4 Performance - 图5 Performance - 图6

参考文档

  1. (callback: Function) => PerformanceObserver
参数 类型
callback Function

getEntries

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

支持情况:Performance - 图7 Performance - 图8 Performance - 图9

参考文档

  1. () => PerformanceEntry[]

getEntriesByName

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

支持情况:Performance - 图10 Performance - 图11 Performance - 图12

参考文档

  1. (name: string, entryType: string) => PerformanceEntry[]
参数 类型
name string
entryType string

getEntriesByType

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

支持情况:Performance - 图13 Performance - 图14 Performance - 图15

参考文档

  1. (entryType: string) => PerformanceEntry[]
参数 类型
entryType string

setBufferSize

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

支持情况:Performance - 图16 Performance - 图17 Performance - 图18

参考文档

  1. (size: number) => void
参数 类型
size number

API 支持度

API 微信小程序 H5 React Native
Performance ✔️
Performance.createObserver ✔️
Performance.getEntries ✔️
Performance.getEntriesByName ✔️
Performance.getEntriesByType ✔️
Performance.setBufferSize ✔️