Skip to content

Commit e013a4c

Browse files
DanTupCommit Queue
authored andcommitted
[analysis_server] Add some notes on how to use the CPU Profiler for the analysis server hosted by VS Code
Change-Id: I1af51746901d0eb579431c277b0cff204f025c42 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/397840 Reviewed-by: Brian Wilkerson <[email protected]> Reviewed-by: Kenzie Davisson <[email protected]> Commit-Queue: Brian Wilkerson <[email protected]> Reviewed-by: Samuel Rawlins <[email protected]>
1 parent 0f723b3 commit e013a4c

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

pkg/analysis_server/doc/process/overview.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ The documentation covers the following topics:
1010

1111
- [Implementing a new language feature](new_language_feature.md)
1212
- [Running/Debugging analysis_server from source in VS Code](running_in_vs_code.md)
13+
- [Profiling the analysis server hosted by VS Code](profiling_for_vs_code)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Profiling the analysis server hosted by VS Code
2+
3+
The steps below show how to use the DevTools CPU profiler against the instance
4+
of the analysis server being hosted by VS Code. This allows profiling a short
5+
window of operations (such as typing in the editor or invoking code completion).
6+
7+
- Open a project in VS Code that can be used to trigger the bad performance
8+
- Run the **Preferences: Open Workspace Settings (JSON)** command from the
9+
command palette (`F1`) or open the `.vscode/settings.json` file
10+
- Add `"dart.analyzerVmServicePort": 8855` (the exact port number is not important
11+
but you'll need it further down)
12+
- Save the settings file
13+
- A toast notification should appear in the bottom right warning you that the
14+
analysis server's VM Service is enabled. This is a reminder that you should
15+
remove the `dart.analyzerVmServicePort` setting when you are done.
16+
- Wait for initial analysis to complete (No "Analyzing..." or spinners in the
17+
status bar)
18+
- Open a file and find a location where you can reproduce the bad performance
19+
- Run the **Dart: Open DevTools in Browser** command from the palette (`F1`)
20+
- In DevTools, enter `http://localhost:8855/` (using the port number from above)
21+
and click **Connect**
22+
- Navigate to the **CPU Profiler** tab
23+
- Click **Enable Profiler**
24+
- In the isolate selector (bottom middle of the page), select the Isolate named
25+
**main**
26+
- Click the **Start recording** button
27+
- Switch back to VS Code and perform the actions that cause bad performance
28+
- Back in DevTools, click the **Stop recording** button in the CPU Profiler
29+
30+
Profiling information should be displayed automatically and can be exported
31+
using the export button on the top right corner. Exported information may
32+
contain paths and class/member names from your project.
33+
34+
When you are done, don't forget to remove the VM Service port from your
35+
workspace settings:
36+
37+
- Run the **Preferences: Open Workspace Settings (JSON)** command from the
38+
command palette (`F1`) or open the `.vscode/settings.json` file
39+
- Remove the `"dart.analyzerVmServicePort": 8855` setting
40+
- Save the settings file

0 commit comments

Comments
 (0)