# Performance wx.getPerformance()

Start from base library version 2.11.0. Please remaining backward compatible.

with Promise style call: Not supported

Mini Program plugin: Support

Gets information about the performance of the current Mini Program. For more on Mini Programs startup performance optimization, seeBoot Performance Guide

# Return value

# Performance

The following types of performance metrics are currently supported:

Indicator Type (entryType) Indicator name
Routing (navigation) route: Routing performanceappLaunch: Mini Program startup time
Render (render) firstRender: First rendering of the page is time-consuming
Script (script) evaluateScript: Injection script time-consuming

Performance data details:

attribute Introductions
entryType Indicator type
name Indicator name
startTime Index Call Start TimeApp Launch is the time to click the icon
duration time-consuming
path Route
navigationStart True Routing Response Start Time
navigationType Route Detail Type

# sample code

const performance = wx.getPerformance()
const observer = performance.createObserver((entryList) => {
observer.observe({ entryTypes: ['render', 'script'] })

# Be careful

Currently, when the code is turned on On-demand injection When,evaluateScript The time to inject code that contains only the public parts, pages, and components is reflected in firstRender Because the code injection process for pages and components becomes part of the first rendering processTherefore, it is normal for script time to decrease and render time to increase after on-demand injection. The optimization effect can focus on overall startup time (appLaunch) to evaluate