You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: microsoft-edge/devtools-guide-chromium/about-tools.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,7 +57,7 @@ Microsoft Edge DevTools includes the following tools.
57
57
|**Network conditions** tool | Use the **Network conditions** tool to disable the browser cache, set network throttling, set the user agent string, and set Content-Encodings such as deflate, gzip, and br. |[Network conditions tool](network-conditions/network-conditions-tool.md)|
58
58
|**Network Console** tool | Use the **Network Console** tool to make changes to network requests (network calls) to see why they fail. Change and replay any of the network requests, and make detailed network API calls. |[Network Console tool](network-console/network-console-tool.md)|
59
59
|**Network request blocking** tool | Use the **Network request blocking** tool to test blocking network requests to a specified URL pattern and see how a webpage behaves. |[Network request blocking tool](network-request-blocking/network-request-blocking-tool.md)|
60
-
|**Performance** tool | Analyze runtime performance, which is how your page performs when it's running, as opposed to loading. |[Get started analyzing runtime performance](evaluate-performance/index.md)|
60
+
|**Performance** tool | Analyze runtime performance, which is how your page performs when it's running, as opposed to loading. |[Introduction to the Performance tool](evaluate-performance/index.md)|
61
61
|**Performance monitor** tool | Provides a real-time view of the runtime performance of a webpage, to determine where performance problems come from, making a website run slowly. Finds whether problems are from high memory or CPU usage, too-frequent layout and style calculations, or too many DOM nodes and event listeners. |[Measure runtime performance of a page using the Performance monitor tool](performance-monitor/performance-monitor-tool.md)|
62
62
|**Quick source** tool | Use the **Quick source** tool to display or edit source files when using a tool other than the **Sources** tool. |[Display or edit source files using the Quick source tool](quick-source/quick-source-tool.md)|
63
63
|**Rendering** tool | Use the **Rendering** tool to see what your webpage looks like with different display options or vision deficiencies. |[Rendering tool, to see what a webpage looks like with different display options or vision deficiencies](rendering-tools/rendering-tool.md)|
Copy file name to clipboardExpand all lines: microsoft-edge/devtools-guide-chromium/evaluate-performance/index.md
+94-25Lines changed: 94 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,11 @@
1
1
---
2
-
title: Get started analyzing runtime performance
2
+
title: Introduction to the Performance tool
3
3
description: Tutorial about how to evaluate runtime performance in Microsoft Edge DevTools.
4
4
author: MSEdgeTeam
5
5
ms.author: msedgedevrel
6
6
ms.topic: conceptual
7
7
ms.prod: microsoft-edge
8
-
ms.date: 11/22/2022
8
+
ms.date: 2/22/2023
9
9
---
10
10
<!-- Copyright Kayce Basques
11
11
@@ -20,15 +20,14 @@ ms.date: 11/22/2022
20
20
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
21
See the License for the specific language governing permissions and
22
22
limitations under the License. -->
23
-
# Get started analyzing runtime performance
23
+
# Introduction to the Performance tool
24
24
25
25
_Runtime performance_ is how your page performs when it's running, as opposed to loading. The following tutorial teaches you how to use the DevTools **Performance** tool to analyze runtime performance.
26
26
27
-
In terms of the **RAIL** model, the skills you learn in this tutorial are useful for analyzing the Response, Animation, and Idle phases of your page.
27
+
The skills you learn in this tutorial are useful for analyzing loading, interactivity, and visual stability of your web content, which are also key indicators for [Core Web Vitals](https://web.dev/vitals/). Each of the Core Web Vitals represents a distinct facet of the user experience, is measurable in the field, and reflects the real-world experience of a critical user-centric outcome. You can see these Core Web Vitals in the **Performance** tool.
28
28
29
-
See also [Optimize website speed using Lighthouse](../speed/get-started.md).
30
-
31
-
<!--todo: add rail link when section is ready -->
29
+
See also:
30
+
-[Optimize website speed using Lighthouse](../speed/get-started.md)
@@ -38,22 +37,22 @@ In the following tutorial, you open DevTools on a "Sluggish Animation" demo page
38
37
39
38
1. Open the [Sluggish Animation](https://microsoftedge.github.io/Demos/devtools-performance-get-started/) demo page in your InPrivate tab or window. To do that, right-click the link and then select **Open link in InPrivate window**. You'll profile this page, which shows a variable number of icons moving up and down. For more information about InPrivate, see [Browse InPrivate in Microsoft Edge](https://support.microsoft.com/microsoft-edge/browse-inprivate-in-microsoft-edge-cd2c9a48-0bc4-b98e-5e46-ac40c84e27e2)
40
39
41
-
Note: The source for this demo is at[MicrosoftEdge / Demos > devtools-performance-get-started](https://github.com/MicrosoftEdge/Demos/tree/main/devtools-performance-get-started).
<!--TODO: replace section when updated for Chromium-based Edge -->
45
44
46
45
<!-- You can view the source files for the "Sluggish Animation" demo page at the [MicrosoftEdge/Demos > devtools-performance-get-started](https://github.com/MicrosoftEdge/Demos/tree/main/devtools-performance-get-started) repo folder. -->
47
46
48
-
1. Press **Ctrl+Shift+I** (Windows, Linux) or **Command+Option+I** (macOS) to open DevTools.
47
+
1. Press **Ctrl+Shift+I** (Windows, Linux) or **Command+Option+I** (macOS) to open DevTools:
49
48
50
49

51
50
52
-
53
-
For the rest of the following screenshots, DevTools is [undocked to a separate window](../customize/placement.md), to better focus on the contents.
51
+
For the rest of the screenshots, DevTools is shown [undocked to a separate window](../customize/placement.md).
54
52
55
53
56
-
### Simulate a mobile CPU
54
+
<!-- ------------------------------ -->
55
+
#### Simulate a mobile CPU
57
56
58
57
Mobile devices have much less CPU power than desktops and laptops. Whenever you profile a page, use CPU Throttling to simulate how your page performs on mobile devices.
59
58
@@ -70,22 +69,24 @@ Mobile devices have much less CPU power than desktops and laptops. Whenever you
70
69
If you want to ensure that pages work well on low-end mobile devices, set **CPU** to **6x slowdown**. The demo doesn't work well with 6x slowdown, so it just uses 4x slowdown for instructional purposes.
71
70
72
71
73
-
### Set up the demo
72
+
<!-- ------------------------------ -->
73
+
#### Set up the demo
74
74
75
75
The following section lets you customize the demo to make sure that your experience is relatively consistent with the screenshots and descriptions.
76
76
77
77
1. Click the **Add 10** button until the blue icons move noticeably slower than before. On a high-end machine, you can click it about 20 times.
78
78
79
79
1. Click **Optimize**. The blue icons should move faster and more smoothly.
80
80
81
-
1. To better display a difference between the optimized and non-optimized versions, click the **Subtract 10** button a few times and try again. If you add too many blue icons, you could max out the CPU, and then you might not observe a major difference in the results for the two versions.
81
+
1. To better display a difference between the optimized and unoptimized versions, click the **Subtract 10** button a few times and try again. If you add too many blue icons, you could max out the CPU, and then you might not observe a major difference in the results for the two versions.
82
82
83
83
1. Click **Un-Optimize**. The blue icons move slower and with more sluggishness again.
84
84
85
85
86
-
### Record runtime performance
86
+
<!-- ------------------------------ -->
87
+
#### Record runtime performance
87
88
88
-
When you ran the optimized version of the page, the blue icons move faster. Why is that? Both versions are supposed to move the icons the same amount of space in the same amount of time. Take a recording in the **Performance** tool to learn how to detect the performance bottleneck in the non-optimized version.
89
+
When you ran the optimized version of the page, the blue icons move faster. Why is that? Both versions are supposed to move the icons the same amount of space in the same amount of time. Take a recording in the **Performance** tool to learn how to detect the performance bottleneck in the unoptimized version.
89
90
90
91
1. In DevTools, click **Record** (). DevTools captures performance metrics as the page runs.
91
92
@@ -116,7 +117,7 @@ Once you have a recording of the page's performance, you can assess the page's p
116
117

117
118
118
119
119
-
120
+
<!-- ------------------------------ -->
120
121
#### Bonus: Open the Frame Rendering Stats overlay
121
122
122
123
Another handy tool is the **Frame Rendering Stats** overlay, which provides real-time estimates for FPS as the page runs. The **Frame Rendering Stats** overlay is not required for this tutorial but may provide helpful insight.
@@ -132,7 +133,8 @@ Another handy tool is the **Frame Rendering Stats** overlay, which provides real
132
133
1. When you are done reviewing the FPS data, clear the **Frame Rendering Stats** checkbox to hide the overlay.
133
134
134
135
135
-
### Find the bottleneck
136
+
<!-- ------------------------------ -->
137
+
#### Find the bottleneck
136
138
137
139
After you verified that the animation isn't performing well, the next step is to answer the question "why?"
138
140
@@ -170,7 +172,7 @@ After you verified that the animation isn't performing well, the next step is to
170
172
171
173

172
174
173
-
The problem with the non-optimized code is that, in each animation frame, it changes the style for each icon, and then queries the position of each icon on the page. Because the styles changed, the browser doesn't know if each icon position changed, so it has to re-layout the icon in order to compute the new position.
175
+
The problem with the unoptimized code is that, in each animation frame, it changes the style for each icon, and then queries the position of each icon on the page. Because the styles changed, the browser doesn't know if each icon position changed, so it has to re-layout the icon in order to compute the new position.
174
176
<!--
175
177
> To learn more, see [Avoid forced synchronous layouts](https://web.dev/avoid-large-complex-layouts-and-layout-thrashing/#avoid-forced-synchronous-layouts).
176
178
-->
@@ -179,12 +181,77 @@ After you verified that the animation isn't performing well, the next step is to
179
181
This article gives you a lot to learn. But now you have a solid foundation in the basic workflow for analyzing runtime performance. Good job.
180
182
181
183
182
-
### Analyze the optimized version
184
+
<!-- ------------------------------ -->
185
+
#### Analyze the optimized version
183
186
184
187
Using the workflows and tools that you just learned, click **Optimize** on the demo to turn on the optimized code, take another performance recording, and then analyze the results. From the improved framerate to the reduction in events in the flame chart in the **Main** section, the optimized version of the app does much less work, resulting in better performance.
185
188
186
-
The optimized code uses a different sequence of actions to do less work. Note that this code could be made even faster by only using properties that only affect compositing, instead of manipulating the `top` property of every icon.
187
-
<!-- > For more information, see [Use transform and opacity changes for animations](https://web.dev/stick-to-compositor-only-properties-and-manage-layer-count/#use-transform-and-opacity-changes-for-animations). todo: add rendering section when available -->
189
+
190
+
<!-- ------------------------------ -->
191
+
#### Unoptimized version
192
+
193
+
Compare this snippet of JavaScript from the unoptimized version of the app:
194
+
195
+
```javascript
196
+
var pos =m.classList.contains("down")
197
+
?m.offsetTop+ distance
198
+
:m.offsetTop- distance;
199
+
if (pos <0) pos =0;
200
+
if (pos > maxHeight) pos = maxHeight;
201
+
m.style.top= pos +"px";
202
+
if (m.offsetTop===0) {
203
+
m.classList.remove("up");
204
+
m.classList.add("down");
205
+
}
206
+
if (m.offsetTop=== maxHeight) {
207
+
m.classList.remove("down");
208
+
m.classList.add("up");
209
+
}
210
+
```
211
+
212
+
The above code snippet runs on every frame of the browser rendering loop, for each blue icon on the page. The `m` variable references a single blue icon.
213
+
214
+
In this unoptimized version, we create a `pos` variable that's set to the current position of the icon, to which we add some distance. The current position of the icon is read by using `m.offsetTop`.
215
+
216
+
After making sure that the icon is still within the bounds of the page, we set its new position by using `m.style.top`, which sets inline styles on the element.
217
+
218
+
Finally, we read `m.offsetTop` again, to adjust the direction of the icon.
219
+
220
+
221
+
<!-- ------------------------------ -->
222
+
#### Optimized version
223
+
224
+
The optimized code uses a different sequence of actions to do less work. Here is the same snippet of JavaScript from the optimized version of the app:
225
+
226
+
```javascript
227
+
var pos =parseInt(m.style.top.slice(0, m.style.top.indexOf("px")));
In the optimized version, we first set the value of the `pos` variable by reading `m.style.top` instead of using `m.offsetTop`. Using the element's inline style is faster, because reading `m.offsetTop` forces the browser engine to know where all the elements are on the page, which requires the engine to recalculate the styles and the layout.
243
+
244
+
We then set the new position of the icon, like done in the unoptimized version, but we don't read `m.offsetTop` again (like done in the unoptimized version) to adjust the icon's direction.
245
+
246
+
The unoptimized code reads and writes the position of the icon from two different places, forcing the browser to recalculate the style and layout on each frame. The optimized version, however, writes and reads the position of the icon in the inline styles only.
247
+
248
+
249
+
<!-- ------------------------------ -->
250
+
#### Further possible optimizations
251
+
252
+
This code could be made even faster by using CSS properties that only require the browser to do compositing, rather than layout. Instead of manipulating the `top` property, which forces the browser to run its layout code again, using the `transform` property would allow the browser to consider each icon as an individual layer, and then display these layers in the correct positions by re-compositing the final image. For example, instead of using `m.style.top = pos + "px";`, we can use `m.style.transform = translateY(pos + "px,");`.
253
+
254
+
To learn more, see [Use transform and opacity changes for animations](https://web.dev/stick-to-compositor-only-properties-and-manage-layer-count/#use-transform-and-opacity-changes-for-animations).
@@ -193,13 +260,15 @@ The optimized code uses a different sequence of actions to do less work. Note th
193
260
<!--The foundation for understanding performance is the RAIL model. The RAIL model teaches you the performance metrics that are most important to your users.
194
261
To learn more, see [Measure Performance With The RAIL Model](https://web.dev/rail/). -->
195
262
196
-
To get more comfortable with the **Performance** tool, practice makes perfect. Try profiling your pages and analyzing the results. If you have any questions about your results, use the **Send Feedback** icon, press **Alt+Shift+I** (Windows, Linux) or **Option+Shift+I** (macOS), or [file an issue on the MicrosoftEdge / DevTools repo](https://github.com/MicrosoftEdge/DevTools/issues). Include screenshots or links to reproducible pages, if possible.
263
+
To get more comfortable with the **Performance** tool, practice profiling your pages and analyzing the results.
264
+
265
+
If you have any questions about your results, use the **Send Feedback** icon, press **Alt+Shift+I** (Windows, Linux) or **Option+Shift+I** (macOS), or [file an issue on the MicrosoftEdge / DevTools repo](https://github.com/MicrosoftEdge/DevTools/issues):
197
266
198
267

199
268
200
-
<!-- To really become an expert in runtime performance, you must learn how the browser translates HTML, CSS, and JS into pixels on a screen. The best place to start is the [Rendering Performance](https://web.dev/rendering-performance/). [The Anatomy Of A Frame](https://aerotwist.com/blog/the-anatomy-of-a-frame/) dives into even more detail. -->
269
+
Include screenshots or links to reproducible pages, if possible.
201
270
202
-
Last, there are many ways to improve runtime performance. This article focused on one particular animation bottleneck to give you a focused tour of the **Performance** tool, but it's only one of many bottlenecks you may encounter. <!-- The rest of the Rendering Performance series has a lot of good tips for improving various aspects of runtime performance, such as: -->
271
+
There are many ways to improve runtime performance. This article focused on one particular animation bottleneck to give you a focused tour of the **Performance** tool, but it's only one of many bottlenecks you may encounter. <!-- The rest of the Rendering Performance series has a lot of good tips for improving various aspects of runtime performance, such as: -->
Copy file name to clipboardExpand all lines: microsoft-edge/devtools-guide-chromium/evaluate-performance/reference.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ ms.date: 05/04/2021
24
24
25
25
This page is a comprehensive reference of DevTools features that are related to analyzing performance.
26
26
27
-
For a step-by-step tutorial on how to analyze the performance of a page using the **Performance** tool, see [Get started analyzing runtime performance](index.md).
27
+
For a step-by-step tutorial on how to analyze the performance of a page using the **Performance** tool, see [Introduction to the Performance tool](index.md).
0 commit comments