抖音开放平台Logo
开发者文档
“/”唤起搜索
控制台
  • JS API 列表
  • 基础
  • tt.canIUse
  • tt.canIPutStuffOverComponent
  • tt.base64ToArrayBuffer
  • tt.arrayBufferToBase64
  • tt.setPageInfo
  • 性能
  • tt.performance.createObserver
  • tt.performance.getEntries
  • tt.performance.getEntriesByName
  • tt.performance.getCurrentPageEntries
  • tt.performance.setBufferSize
  • PerformanceEntry
  • tt.performance.clearMarks
  • tt.performance.mark
  • tt.performance.getEntriesByPage
  • tt.performance.getEntriesByType
  • 线程
  • 窗口尺寸变化
  • 生命周期
  • 版本更新
  • 定时器
  • 应用级事件
  • 环境变量
  • TTML
  • 网络
  • 媒体
  • 地图
  • 文件
  • 数据缓存
  • 地理位置
  • 设备
  • 画布
  • 界面
  • 页面导航
  • 开放接口
  • 行业开放
  • 第三方平台
  • 其它
  • 生活服务(即将废弃)
  • 小程序智能体
  • PerformanceEntry
    收藏
    我的收藏

    单条性能数据。具体数据口径示意图请参考小程序启动流程

    属性

    属性
    类型
    默认值
    说明
    name
    string
    该 performance entry 的名字,指标名字。
    entryType
    string
    代表所上报的 performance metric 的 entryType 类型,例如 "mark"、"paint"。详细见 属性取值
    startTime
    number
    为该性能埋点的上报时间戳。此属性的含义取决于此项的 entryType 的值。
    duration
    number
    持续时间,单位 ms。此属性的含义取决于此项的 entryType 的值。
    path
    string
    页面路径,仅 type 为 paint 和 evaluate 时才可能存在
    fileName
    string
    文件名,仅 name 为 app-service 存在
    packageName
    string
    包名字(分报名/主包为APP),仅 name 为 app-service 或者 miniprogram-package 存在
    packageSize
    number
    包大小,单位Byte 字节,仅 name 为 miniprogram-package 存在
    navigationType
    string
    路由详细类型,仅 type 为 navigation 时存在
    取值为 appLaunch 时表示冷启动,其他场景取值为路由类型,同路由API名
    referrerPath
    string
    页面跳转来源页面路径,仅 type 为 navigation 时存在
    uri
    string
    资源路径,仅 name 为 resource-timing 时存在
    initiatorType
    string
    资源类型(合法资源类型:image、open-data),仅 name 为 resource-timing 时存在
    transferSize
    number
    获取资源的大小,仅 name 为 resource-timing 时存在
    domainLookupStart
    number
    解析域名开始时间,仅 name 为 resource-timing 时存在
    domainLookupEnd
    number
    解析域名结束时间,仅 name 为 resource-timing 时存在

    属性取值

    name
    entryType
    描述
    app-click
    launch
    用户小程序入口点击时记录,duration 表示从点击到开始创建页面的耗时。若需要统计 LCP,可通过 largest-contentful-paint 的 startTime 减去 app-click 的 startTime。
    startTime:点击入口时的时间戳
    duration:从点击入口到路由开始
    miniprogram-package
    resource
    小程序包下载记录,仅在本地没有小程序包时上报,如首次打开小程序或小程序版本更新后首次启动。
    startTime:开始下载小程序包的时间戳
    duration:小程序代码包下载耗时
    packageName:所在包名,分包名 / 主包为 __APP__
    packageSize:包大小,单位Byte 字节
    app-service
    evaluate
    小程序逻辑层启动入口执行。
    startTime:小程序逻辑层入口文件App.js 开始加载的时间戳
    duration:小程序逻辑层入口文件App.js 加载耗时,包含App.js 文件及相关依赖的加载执行,App.onLaunch, App.onShow 的执行耗时总和
    fileName:取值 "app-service.js",即小程序逻辑层入口编译产物文件名
    packageName:所在包名,分包名 / 主包为 __APP__
    logic-create-page
    evaluate
    启动路由后逻辑层收到创建页面消息时记录。
    startTime:逻辑层页面开始创建的时间戳
    duration:逻辑层创建页面的耗时。包含页面入口JS的加载、模版文件加载(如有依赖)、Page.onLoad 执行
    view-create-page
    evaluate
    视图层页面创建。
    startTime:视图层文件加载完成的时间戳(TTML, TTSS)
    duration:视图层创建页面的耗时。即从视图层文件加载完成到首次渲染完成耗时。包含接收初始渲染数据,渲染耗时。
    first-paint
    paint
    首次渲染时记录。
    startTime:首次渲染完成的时间戳
    duration:始终取值为0,无实际含义
    first-contentful-paint
    paint
    页面首次内容绘制(FCP)时间点。
    startTime:FCP 触发时的时间戳
    duration:始终取值为0,无实际含义
    largest-contentful-paint
    paint
    页面最大内容绘制(LCP)时间点。若需要统计 LCP,可通过 largest-contentful-paint 的 startTime 减去 app-click 的 startTime。
    startTime:LCP 触发时的时间戳
    duration:始终取值为0,无实际含义
    resource-timing
    resource
    视图层资源加载耗时。
    startTime:资源加载过程开始之前的时间戳
    duration:视图层资源加载耗时
    uri:资源路径
    目标页面的 URL
    navigation
    页面路由时记录,包含启动和其他形式的路由跳转。
    startTime:路由开始的时间戳
    duration:从路由开始到页面首次渲染完成
    navigationType:路由类型。取值为 appLaunch 时表示冷启动,其他场景取值为路由类型,同路由API名
    referrerPath:页面跳转来源页面路径
    initiatorType:资源类型(合法资源类型:image、open-data)
    transferSize:资源大小,属性介绍
    domainLookupStart:解析域名开始时间,属性介绍
    domainLookupEnd:解析域名结束时间,属性介绍
    mark 的参数名
    mark
    调用 tt.performance.mark 上报。
    startTime:上报时的时间戳
    duration:始终取值为0,无实际含义

    代码示例

    const entries = tt.performance.getEntries(); for (let i = 0, len = entries.length; i < len; i++) { console.log("entry name: " + entries[i].name); console.log("entry entryType: " + entries[i].entryType); console.log("entry startTime: " + entries[i].startTime); console.log("entry duration: " + entries[i].duration); }

    Bug & Tip