开发者社区
社区提问意见反馈
开发者钉组织
扫描二维码
加入支付宝开发者钉组织
基础 api
基础
性能
performance
performanceobserver
entrylist
performanceentry
调试
应用级事件
界面
跳转
多媒体
缓存
文件
位置
网络
设备
worker
数据安全
分享
收藏
自定义通用菜单
更新管理
web-view组件控制
升级支付宝最新版本
隐私信息授权
小程序广告
开放能力 api
开发 > api > 基础 api > 基础 >  > my.getperformance
收藏
订阅更新
我的文档
设置

my.getperformance()

基础库 2.9.9 或更高版本; 若版本较低,建议采取 兼容处理

支小宝客户端 支持

安诊儿客户端 支持

插件: 不支持。

主体: 企业支付宝小程序个人支付宝小程序

相关文档: 小程序运行机制

获取小程序相关性能数据。

获取 performance 示例
page({
  onready() {
  _if (my.getperformance) {
      // 获取 performance 实例
      const performance = my.getperformance();
      // 创建 observer
      const observer = performance.createobserver((entrylist) => {
        console.log(entrylist.getentries());
      });
    }
  }
})
  • tip
    this.getperformance() 返回值与 page / component 所在页面绑定,且返回值始终相同。
  • tip
    setbuffersizesetbatchtimeout 会对整个 performance 生效。
  • tip
    component 不能跨主体调用,否则返回 null。例如:插件自定义组件无法获得宿凯发k8官方网娱乐官方主页面的 performance
  • tip
    不同页面之间的 performanceentry 是隔离的,即 a页面 无法监听 b页面 的 entry 变化。
  • tip

    由于 observer 只会回调每次新增内容,若你需要完整内容,可通过 performance.getentries() 获得,也可自行创建个数组存储。如:

    page({
      data: {
        performancedata: [],
      },
      onready() {
        const performancedata = this.data.performancedata;
        const performance = my.getperformance();
        const observer = performance.createobserver((entrylist) => {
          performancedata.push(...entrylist.getentries());
        });
        observer.observe({ entrytypes: ['render'] });
      },
    });
    
内容没有解决您的问题?您还可以前往 或 寻求帮助
凯发k8官方网娱乐官方 copyright © 2022 支付宝(杭州)信息技术有限公司  | icp证浙b2-20160559
该文档对你是否有帮助?
当前页面目录
网站地图