# Weixin Mini Program Speed measurement

This capability has been removed from the shelf. Please migrate to We analyze to use the relevant capability.

To help developers optimize Weixin Mini Program performance, we have introduced the "Mini Programs speed" feature."Picicle Speed" can easily and conveniently calculate the real time consumption of an event within a Mini Program, and can carry out real-time cross-analyses based on key dimensions such as geography, carrier, operating system, network type, and aircraft model. Starting with Repository 2.9.2, when a developer reports the time consumption of a metric through the "Speed Report" interface, they can view the time usage trends of each metric in the application management back-end "Development - Operations Center - Application Speed Report" and support real-time viewing of minute-level data.

# New Monitoring ID

In order to achieve time-consuming monitoring of a given indicator, a developer needs to define the monitoring indicator first.In Weixin Mini Program management background ( mp.weixin.qq.com )In the "Development - Operation and Maintenance Center - Mini Programs Speed" new monitoring ID, and fill in the name and explanation of monitoring indicators.

img

Click "New" to create a new ID, you need to select the indicator type, and fill in the indicator name and the corresponding explanation of the indicator. Monitoring indicators fall into two categories:

Network request type : This type of time is mainly affected by the network environment, including statistical dimensions such as operating system, carrier, network environment, and region.For example: network API time consuming, cloud call time consuming, network data read and write time consuming. Note that up to 20 such indicators can be created.

Loading / rendering class : This type of time is mainly affected by the performance of the device, including statistical dimensions such as operating system, model category, etc.It can be used to measure page switching time, component rendering time, etc. Note that up to 20 such indicators can be created.

img

When you create it, you can see the monitoring ID you need to use for reporting.

img

# Speed reports

After the developer defines the monitor ID, it needs to call wx.reportPerformance in Weixin Mini Program codeThe interface reports time consumption values to allow time monitoring:

Reporting method 1: Use rubbing color to judge

// * You need to use a brush color to determine whether the interface is available
if (wx.canIUse('reportPerformance')) {
  wx.reportPerformance(id, val)
}

Reporting method 2: Use compareVersion to determine

// * Need to use compareVersion first to determine if the interface is available
const sdkVersion = wx.getSystemInfoSync().SDKVersion
if (compareVersion(sdkVersion, '2.9.2') >= 0) {
  wx.reportPerformance(id, val)
}

Id and val are uint32 types, where id is the monitoring ID defined by the Weixin Mini Program management background, and val is the time consuming value to be reported (calculated by the developer).Interface calls require a base library version number higher than 2.9.2, otherwise the base library may report an error in some lower versions.

(compareVersion Definition )

# Data observations

After completing the code report, you can view the time consuming trend of each indicator in the Weixin Mini Program management background "Development - Operation and Maintenance Center - Mini Programs Speed."At present, online data has a data delay of about 15 minutes, reporting data is retained for 7 days, and can be aggregated by different time granularity such as 1 minute - 1 hour.

Two curves can be observed for each indicator, the average curve and the number of reports.

img

At the same time, for different dimensions of data, we provide cross-comparison functions to help you complete the analysis quickly and conveniently, bearing in mind that the number of cross-comparison curves cannot exceed 10. img

For network request metrics, we provide a regional map to help you quickly locate regional resource issues. img

# Custom dimensions (optional functionality)

For more complex user scenarios, users may need to break down the measurement data by url, page, and other dimensions, so we provide a custom dimension, where users can fill in some dimension character strings at the business level to facilitate business analysis. Currently, the number of custom latitude values per indicator needs to be limited to 50 (excessively limited data is discarded) and the length of custom dimension values needs to limit to 256 bytes (excessively restricted values are intercepted). The effects of custom dimensions are as follows: img To use a custom dimension, just add the third parameter dimensions to wx.reportPerformance to report the custom dimension:

wx.reportPerformance(id, value, dimensions)

Documentation for wx.reportPerformance

# Q&A

Q: In what scenarios can the speed measurement system work?

A: You can measure network type indicators (such as network call / cloud call time, network data read and write speed, etc.) and non-network type indicators (page switching loading speed, component rendering speed, etc.). You can see the quantitative distribution and performance differences of these indicators in different dimensions. In some scenarios of calculating video first screen delay, frame rate, etc., it can also play a role.

Q: What is the base library version required for reporting the API?

A: Base library version 2.9.2 or above is required. In some low version of the base library may report an error, the follow-up will support the use of caniuse interface to determine.

Q: Is the system available in beta? What is the expected delay in reporting? How long is the data saved?

A: Can be used in the beta version, the current report delay is about 15 minutes. The data will be saved for 7 days.

Q: How many indicator IDs can I define?

A: A single Weixin Mini Program category can define 20 IDs.