This article is from chrome’s official documentation: Portal (requires scientific Internet access)
Chrome’s developer tools provide a number of efficient tools for analyzing page performance. I used to only use some basic functions, but recently I went through the official documentation in detail, especially the use of the Performance panel (mostly the old Timeline panel) (which requires a relatively new version of Chrome).
The purpose of this article is to share the basics of performance analysis using Chrome, without going too far into the specific causes of performance problems
The preparatory work
First, there are a few things to prepare for the analysis:
- Go into incognito mode to avoid interference from browser plugins
- Open the
performance
TAB - Click the pinion icon on the far right of Settings and open it if it is a mobile project
CPU
Throttling switch, select the corresponding one according to computer performance (used to simulate the performance of mobile phone) - Open the screenshot
Screenshots
Take a screenshot of each frame during the process - If it’s checked
memory
You can also see the different components of the memory footprint (ex:Heap,node…) In the recording process changes, according to the change of the situation to see the general garbage collection cycle, and whether there are obvious memory leaks.
Official case Study
According to the above preparation to open, if not open temporarily look at my side of the picture taken;
record
loading
demo
Let’s first introduce the meaning of the information in each part of the figure:
- The right side of the picture is marked with:
FPS; CPU; NET
-
First, the Analyze frames per second frame rate; The red bar on an FPS shows that the low framerate has affected the user experience, and generally the higher the green bar, the higher the framerate, the better the experience. Horizontal bars do not appear when frame rates do not affect usage.
-
Next comes cpu-related analysis: the following figure
CPU
The corresponding bar is belowsummary Tab
The color bars in this part also correspond to each other. The higher the proportion rightCPU
The more you consume. fromsummary Tab
We can also see that most of our time is actually spent inrendering
This also indicates that the problems in our demo are most likely in the rendering-related code. -
Moving the mouse left and right on FPS,CPU, or NET allows you to view screenshots at various points in time, which is especially useful when analyzing the various stages of animation execution and loading.
- Then the part with the name on the right:
-
If there is a Network request in the recording period, there is also a column Network above the frame, which is colored to indicate the request for different resources
-
Then there’s the Frames area: hover over it to read the frame rate at the time
-
While recording, press CMD + Shift + P and type Show Rendering (open the live View frame rate panel) to see the real-time frame rate change
-
Main represents the main thread, and a bar represents the execution of an event (function). The longer the length, the more time it takes; Vertical represents the call stack. If the upper right corner of these bars is red, it indicates that there may be a performance problem during the execution of the code.
At this point, we can see that many of the yellow bars in the image above are red in the upper right corner, so let’s check out the performance bottlenecks in the official demo by clicking on this section in main: Click on the Animation Frame Fired event and you can see the information below. And you can locate the relevant code in the Source panel. According to the code segment located, reading the code, we can see that the problem is in the selected line of code with the blue background
Why is there a problem with this code? It’s mandatory to trigger layout, which involves rearranging and redrawing, but I won’t expand here. Those who are interested can click on the reference links below to learn more.
- Reference link 1- Google’s official documentation
- Reference Link 2
The performance Tab is the same as the Summary Tab.
- Bottom-Up Tab
ε¨
Timeline
Select a period of time and clickBottom-Up
The resulting image shows the time taken by each operation performed by the browser - Call-tree Tab
Just click on
Call Tree
The image above shows the basic actions of the browser (event execution, drawing…). Time taken - Event log Tab
Just click on
Event Log
You get the figure above: you can view the elapsed time of event execution in the order in which the events occurred during the selected time.
The images in this article are from the official Chrome Developer Tools documentation.
Spread the word
This article is published in Front of Mint Weekly. Welcome to Watch & Star.