# Startup Performance Analysis

Weixin Mini Program Startup is a very important part of the Mini Program experience, and too long startup time will cause the loss of Mini Program users and affect the experience. In general, optimizing Mini Program startup performance is optimized for the longer cold start performance.

In the Weixin Mini Program startup process, code pack preparation, Mini Program code injection, and home page rendering time are related to Mini Programs themselves, and developers can do some optimization work.

In cold startup, the two most common user scenarios are:

  • First visit by user (code pack required)
  • User is not first time access (Code Pack has been downloaded)

Startup performance analysis dedicated test analyzes the startup time of Weixin Mini Program during the above three phases by testing the above two conditions multiple times, helping users to improve startup performance targeted.

In order to give users more experience with the ability to start performance analysis, each project can start the performance analysis task for the first time free of charge.

# Start quickly.

After entering the cloud test service, click on the top right of the page to create a new task , choose the test type to start the performance analysis , select the test platform and click to create to create a new task.

Once the task is launched, **is performed 10 times separately for the user's first visit and non-first visit Weixin Mini Program-END]]. The user can see the details of the startup performance test by viewing the report.

# View the report

At the end of the task, the user can access the report page by directly clicking the to view the report button on the test task page.

The report detailed the test results for both first-time access (code packets need to be downloaded) and non-first-time access, and showed the average time-consuming distribution through time series diagrams, allowing users to clearly see the time-consume distribution and identify performance bottlenecks.

In addition, the report also provides optimization recommendations to help users improve Weixin Mini Program startup performance.

See Sample Startup Performance Report for details

# Advanced Use - Supports analysis of specified pages

Start performance analysis is generally to analyze the performance of the Weixin Mini Program home page.Now cloud testing also supports analyzing the pages specified by the user, and the specific methodology is as follows:

# 1. In a test plan, configure specified page information

Users can go to Test Case Management = > Test Plan in the left navigation bar to add a test plan for specified pages

# 2. When submitting a task, choose to specify a test plan

When submitting a test task, select the test plan configured in Step 1

# 3. View the report

In test reports, users are enabled to view configuration page information

In addition, users can view screenshots of the page by to pull up Weixin Mini Program details in and to view screenshot of the page

# Proposals for improvement

In general, developers can use several aspects mentioned in the following table to optimize startup performance

Key indicators Optimization recommendations
Code pack preparation 使用 分包 加载

避免使用非必要的全局自定义组件和插件

压缩资源文件 或将资源文件放到CDN

删除没有使用的文件或者模块
Code Injection 开启 按需加载

减少生命周期中的同步API调用

避免进行复杂的运算逻辑
Home Rendering 初始渲染缓存

避免引用未使用的自定义组件

精简首屏数据

提前首屏数据的请求

缓存请求数据

使用 骨架屏

Cloud testing also integrates the performance diagnostic tool capabilities, and more detailed improvements are proposed in the startup performance section of the Weixin Mini Program quality inspection report.

It is strongly recommended that developers use quality inspection reporting capabilities to combine automatic testing and startup testing to better understand the performance of Weixin Mini Program

# Common problem

# 1. Why is there a gap between my startup performance data and our analysis?

The startup performance data of the cloud test is the integration of the results of the single test.** , We analyzed Weixin Mini Program for all online versions for the average of the large disk data so it is normal to have a certain gap between the two.

# 2. Why does the launch of the experience / development version take a lot more time than the online version?

Weixin Mini Program The start-up process for the experience and development versions is different, with some differences in each step of code pack download, Mini Program code injection, and the initial rendering of the front page. There is no point in comparing the two.

For more details, please refer to Weixin Mini Program Startup Process

In general, cloud testing recommends that developers use the online version startup performance to compare with the older version after the new version is released, and the accuracy will be higher.

# 3. In a time-consuming time series diagram, why not start at 0? There are a lot of missing stages in there. What's going on?

The complete startup process can be described in detail in Weixin Mini Program Startup Process .

As can be seen from the flow diagram, the whole process is far more than the three stages of code package download, code injection and the first rendering of the home page.

The startup performance report only shows these three stages because these three stages of time are related to the Weixin Mini Program itself, and developers can optimize

The missing part of the timeline is the initial work done by the WeChat Client and base library, which the developer cannot modify and is not shown in the report.

For example, it can be seen from the startup process that before the code packet is downloaded, it is also necessary to obtain the basic information, code packet address, and other operations from the WeChat background, so the actual download of the code packs must not start from 0ms.

# 4. Why is the total time spent data a lot larger than the code pack download time + code injection time + the home page initial rendering time?

As you can see from FAQ 3, the startup process is much more than just these three stages, so there is no necessarily correlation between "total startup time" and "package download time + code injection time + home page initial rendering time"

# 5. Why does it take different time to download a code package? Is the gap even larger?

The download code package download speed is mainly the mobile phone connection WIFI current speed, as well as the code package CDN cache location

Because the cloud test is the real machine test, the real machine speed is not constant , there is a gap, and even the gap is relatively large, it is normal

Therefore, each time the cloud test does the startup performance test, it will try to draw multiple averages to balance the difference in network speed.

If you find a large gap, you can also run the data several times to see. If you still have a problem, you are welcome to join the official cloud testing microgroup in the help page, scan the code, and contact the group owner for feedback.

# 6. Why the developer tool shows code pack size inconsistent with cloud testing

The developer tools display the Weixin Mini Program source package size.The cloud test shows that the source package is compiled, confused and a series of operations, the actual download code package size on the real machine.

In general, the sizes of the real-world code packages displayed by cloud testing will be larger than the source code packages shown in the developer tools.

In addition, developers focus on download package size

# 7. Why did the performance test be launched and give so few recommendations for optimization, while the quality inspection report gave many more recommendations?

First, the QC report starts performance optimization detection using the performance diagnostic tool capability

The performance diagnostic tool needs to do some additional work in order to collect data.These operations will reduce Weixin Mini Program startup performance

Therefore, in the startup performance specific test, no performance diagnostic tool is turned on, and Weixin Mini Program is directly turned on to obtain data from all aspects of startup performance from client reporting data to ensure the accuracy of the data.

# I need help.

If you have any suggestions or needs, welcome to need help page, scan the code to join the cloud test official enterprise micro group, contact the group main feedback.