# Performance data
To better help developers understand and analyze Weixin Mini Program performance, we provide performance-related statistics on the Mini Program Assistant Mini Program.Developers can also conduct their own reporting analysis based on business needs.
# 1. Get performance data
# 1.1 Analysis by We
We analyze - "Performance Quality" - "Performance Data" also provides a view of some performance data, which is still being improved.
# 1.2 Obtained in Weixin Mini Program via wx.getPerformance
Developers can use wx.getPerformance to obtain current Weixin Mini Program performance-related information, including some time information that cannot be retrieved directly in JavaScript code. In addition, developers can also target their own business needs in a Mini Program.
Specific indicators are described as follows:
- AppLaunch: Weixin Mini Program Startup time consuming.
- The starting point is the time when the user clicks the Weixin Mini Program icon, or when the Mini Program is pulled up;
- The end point is the end time of the first page LargestContentfulPaint.
- Route: Page switching time consuming.
- Start by triggering page switching;
- The end point is the end time of the page LargestContentfulPaint;
- For details, see the page Handover Performance Documentation .
- FirstRender: The page takes time to render for the first time.
- The starting point is that the logical layer receives the routing event, including the time when the logical layer page and the component are initialized, the VD is synchronized, and the rendering layer performs the rendering.
- End of page onReady;
- For details, see the page Handover Performance Documentation .
- FirstPaint (FP): The page is drawn for the first time
- The time when the page was first rendered (the first pixel rendered to the screen);
- firstContentfulPaint(FCP):
- The time the page was first rendered (the first piece of content rendered to the screen);
- Specific meaning can refer to < First Contentful Paint >
- largestContentfulPaint(LCP):
- of the maximum content of the page;
- Specific meaning can refer to < Largest Contentful Paint >
- EvaluateScript: Logical layer JS code injection (including compilation and execution) time-consuming.
FP, FCP, LCP is only a point in time, not a time period, no duration
After obtaining the data, developers can report it themselves or use the "Weixin Mini Program Speed Measurement" for speed analysis.
# 1.3 Through a server interface
This can be obtained through the service interface getPerformanceData .
# 2. Factors that affect startup time
It is highly recommended to read this section carefully to avoid pointless work before you need to start an analysis of Weixin Mini Program time-consuming data.
According to the startup process described in [Weixin Mini Program Startup Process]]](./start_process.md) , there are many factors that affect the time spent on Mini Program startups, and analyzing Mini Program startup performance is a very complex process.
For the same Weixin Mini Program, the following factors directly affect the average startup time of the market:
- Platform : There are large differences in device performance, operating system, framework implementation, optimization scheme, and startup time under different platforms (Android, iOS, PC, etc.). It is only meaningful to compare start-up time (including the time spent at each stage) by platform .
- Download ratio : Code pack downloads and updates can significantly affect Weixin Mini Program startup time. In cases where other processes are stable, an increase in the download ratio can affect disk startup time.
- Entry page : When different pages start, the number and size of code packages to download and the amount of code injected vary according to the subcontract where they are located.There are also differences in page rendering time.
- Type distribution : There is a strong correlation between startup time and device performance, and differences in user groups in different Weixin Mini Program or usage scenarios may lead to differences in model distribution, which in turn affects boot startup time.
- Network environment : The network environment mainly affects the time of network requests, such as Weixin Mini Program information acquisition, code package download, etc.
In addition, the following circumstances may indirectly affect startup time:
- Scenario / access source : In different scenarios, users visit different pages, and the proportion of new users is also different, which will have a certain impact on the startup time.In addition, there are differences between the purpose of the user's visit and their own willingness to wait, which can also affect the opening rate.
- First-time user ratio : The first time a user accesses Weixin Mini Program-END]], the full process of preparation of Mini Program information, code pack download, code cache regeneration, and startup time is higher than non-first-time access.
- Weixin Mini Program version update : When the Mini Program version is updated, the user needs to update the Mini Program information and code packages, the code cache needs to be regenerated, and the startup time increases.
# 3. Startup Data FAQ
(1) Why is there a big difference between "total startup time" and "download time," "js injection time," and "initial rendering time"?
Although total startup time includes the download, js injection, and initial rendering phases, there is no necessarily correlation between total startup time and download time + js execution time + initial rendering time in the performance data.There are several reasons for this:
- The granularity of these metrics is inconsistent: total startup time is granularity based on a cold startup, download time is granullarity based upon a code pack, js injection time is granularly based against a file, and initial rendering time is granauly based on pages, not one-to-one.
- Downloads, JS injections, and initial renders don't just happen at startup.
- Downloading may also occur in scenarios of page switching, sub-packaged pre-downloading. You do not necessarily download a code pack during the startup process, nor do you necessarily download just one code pack.
- JS injection can also occur during page switching and Weixin Mini Program runs.One or more files may be injected during startup and are affected by dimensions such as caching.
- The first render may also occur during page transitions and is also affected by dimensions such as caching
- These several time consuming values are averages in themselves, involve different dimensions, have no correspondence, and the solving and solving is meaningless.
- Download time, js injection time, initial rendering time is only to provide developers with reference to optimize each stage of time, and can not be used to calculate the relationship with the total startup time
- In addition to these three parts of the startup process, there is also time consuming for Weixin Mini Program related information and runtime environment preparation under certain conditions.This part of the time is also not necessarily related to "total startup time - download time - js injection time - initial rendering time."
(2) Why does the time spent on each stage of the start-up decrease and the total time spent increase?
The decrease in mean time for each stage does not necessarily reflect a decrease in total time .for example
- Weixin Mini Program After the release of a new version, even if the time of each stage is reduced, the increase in the download proportion may lead to an increase in the total time.
- A sudden spike in downloads from a very small sub-package may reduce the average download time, but it does not have a significant impact on startups.
(3) Why does each Weixin Mini Program version release lead to an increase in startup time over a period of time?
After the new version of Weixin Mini Program is released, in order to ensure that users switch to the latest version as soon as possible, users need to wait for the synchronized update of the Mini Program when the Mini Program is started (for specific policies, please refer to Mini Program update mechanism ).
In addition to requiring a redownload of the code bundle, version updates also cause caches containing Weixin Mini Program information caches, Code Caching, and initial rendering caches to be updated, and also affect the time it takes for the Mini Program to start for the first time after the update.In general, startup time returns to a stable level within a few days of release.