# Mini Program speed measurement
This capability has been removed, please migrate to We analyze Use relevant capabilities.
To help developers optimize the performance of Mini programs, we launched the "Small Program Speed Measurement" function. The "Mini Program Speed Measurement" can simply and easily calculate the real-time time consumption of an event in the Mini Program, and can perform real-time cross-analysis according to key dimensions such as region, operator, operating system, network type, and model. Starting from the base library 2.9.2, after the developer reports the time-consuming situation of a certain indicator through the "speed report" interface, it can be used in the Mini Program management background. "Development - Operations and Maintenance Centre - Mini Speed Measurement " View time consuming trends for each indicator and support real-time viewing of minute-level data.
# New monitoring ID
In order to achieve time-consuming monitoring of a metric, developers need to first define monitoring metrics. In the Mini Program management background (mp.weixin.qq .com :"Development - Operations and Maintenance Centre - Mini Speed Measurement "New Monitor ID, and fill in the name and explanation of the monitoring indicator.
Click "New" to create a new ID , you need to select the indicator type and fill in the indicator name and the corresponding explanation for the indicator. Monitoring indicators fall into two categories:
Network Request Class: This kind of time is mainly affected by the network environment, including the operating system, operators, network environment, region and other statistical dimensions. Such as: Network api Time, cloud call time, network data read and write time, etc. Note that up to 20 such indicators can be created.
to load/Rendering class: Such time consuming is mainly affected by device performance, including statistical dimensions such as operating system and model category. Can be used to measure page switching time, component rendering time, etc. Note that up to 20 such indicators can be created.
After the new, you can see the monitoring that needs to be used for reporting ID 。
# Speed reporting
After the developer defines the monitoring ID, you need to call the wx.reportPerformance Interface to report the time value, to achieve time monitoring:
Reporting Method 1: use Nuff To judge
// * Need to use Nuff Determine if the interface is available
if (wx.canIUse('reportPerformance')) {
wx.reportPerformance(id, val)
}
Reporting Method 2: Use compareVersion To judge
// * Need to be used first compareVersion 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 All are uint32 Type, in which id Monitoring defined for the Mini Program management background ID,val For the time to report the value (calculated by the developer). Interface calls require a higher version number of the base library than 2.9.2, otherwise in some low version of the base library may error.
(compareVersion definition
# Data observation
After the completion of the code report, the Mini Program management background "Development - Operations and Maintenance Centre - Mini Speed Measurement " View time consuming trends for each indicator. At present, the online data has about 15 minutes of data delay, reported data retention 7 Day, may be in accordance with 1 minute - 1 Hours and other different time granularity were aggregated.
Two curves can be observed for each index, which are the average curve and the number of reports curve.
![img](./img/3.png)
At the same time, for different dimensions of data, we provide a cross-comparison function to help you quickly and easily complete the analysis, pay attention to the number of cross-comparison curves can not exceed 10.
For the Network Request category indicators, we provide regional maps to help you quickly locate regional resource issues.
# Custom Dimensions(Optional features)
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 metric needs to be limited to 50 (over-limit data is discarded), and the length of custom dimension values needs to be limited to 256 bytes (over-limit values are truncated). The effect of using a custom dimension is as follows:
To use a custom dimension, just add the third parameter dimensions to wx.reportPerformance to report the custom dimension:
wx.reportPerformance(id, value, dimensions)
# Q&A
Q : What are the scenarios in which the speed measuring system can be used?
A : Network class metrics such as network calls can be measured/Cloud call time, network data read and write speed, etc.) and non-network indicators (page switching load speed, component rendering speed, etc.). You can view the distribution and performance differences of these metrics in different dimensions. It can also play a role in some scenarios such as calculating the first screen delay and frame rate of video.
Q : What is the base library version required for the Escalate API?
A : Base library version required 2.9.2 Above. In some low version of the base library may report an error, the subsequent support with Nuff Interface for judgment.
Q: Is the system available in beta? What is the approximate delay reported? How long is the data stored?
A : Can be used in the beta version. Currently the reported delay is 15 Minutes or so. Data will be saved 7 Oh, god.
Q: How many indicators can I define ID?
A : Single Mini Program. Each category can be defined 20 individual ID。