Skip to content

Commit e1c45ba

Browse files
committed
profiler docs
1 parent 779627a commit e1c45ba

File tree

6 files changed

+36
-16
lines changed

6 files changed

+36
-16
lines changed

docs/make.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ makedocs(
2727
"Table Viewer"=>"userguide/grid.md",
2828
# "Understanding Code" => "userguide/understandingcode.md",
2929
"Linter"=>"userguide/linter.md",
30+
"Profiler"=>"userguide/profiler.md",
3031
# "Tasks" => "userguide/tasks.md",
3132
"Debugging"=>"userguide/debugging.md",
3233
"Compiling Sysimages"=>"userguide/compilesysimage.md",

docs/src/images/profiler1.png

98.5 KB
Loading

docs/src/images/profiler2.png

35.6 KB
Loading

docs/src/images/profiler3.png

42.5 KB
Loading

docs/src/index.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,3 @@ If you have any issues with this setup, check out the [FAQ](@ref) first. If it d
1717
## User Manual
1818

1919
The following pages are the user manual. These describe how to install and use the Julia extension on VS Code, along with answer questions most new users encounter.
20-
21-
- [Running Code](https://www.julia-vscode.org/docs/stable/userguide/runningcode/)
22-
- [Julia Environments](https://www.julia-vscode.org/docs/stable/userguide/env/)
23-
- [Code Navigation](https://www.julia-vscode.org/docs/stable/userguide/codenavigation/)
24-
- [Editing Code](https://www.julia-vscode.org/docs/stable/userguide/editingcode/)
25-
- [Formatting Code](https://www.julia-vscode.org/docs/stable/userguide/formatter/)
26-
- [Plot Gallery](https://www.julia-vscode.org/docs/stable/userguide/plotgallery/)
27-
- [Data Grid](https://www.julia-vscode.org/docs/stable/userguide/grid/)
28-
- [Understanding Code](https://www.julia-vscode.org/docs/stable/userguide/understandingcode/)
29-
- [Linter](https://www.julia-vscode.org/docs/stable/userguide/linter/)
30-
- [Tasks](https://www.julia-vscode.org/docs/stable/userguide/tasks/)
31-
- [Debugging](https://www.julia-vscode.org/docs/stable/userguide/debugging/)
32-
- [Compiling Sysimages](https://www.julia-vscode.org/docs/stable/userguide/compilesysimage/)
33-
- [Julia Markdown Documents](https://www.julia-vscode.org/docs/stable/userguide/weave/)
34-
- [Remote Development](https://www.julia-vscode.org/docs/stable/userguide/remote/)
35-
- [Settings](https://www.julia-vscode.org/docs/stable/userguide/settings/)

docs/src/userguide/profiler.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Profiling code
2+
3+
Julia comes with it's own [sampling profiler](https://docs.julialang.org/en/v1/stdlib/Profile/) and there are [various packages](https://github.com/timholy/FlameGraphs.jl) to visualize these profile traces.
4+
5+
The VS Code extension comes with it's own profile viewer. Profiling the example function from the [ProfileView.jl readme](https://github.com/timholy/ProfileView.jl)
6+
```
7+
function profile_test(n)
8+
for i = 1:n
9+
A = randn(100,100,20)
10+
m = maximum(A)
11+
Am = mapslices(sum, A; dims=2)
12+
B = A[:,:,5]
13+
Bsort = mapslices(sort, B; dims=1)
14+
b = rand(100)
15+
C = B.*b
16+
end
17+
end
18+
19+
# compilation
20+
@profview profile_test(1)
21+
# pure runtime
22+
@profview profile_test(10)
23+
```
24+
shows a flame graph and inline annotations:
25+
![profiler 1](../images/profiler1.png)
26+
27+
Clicking on any element in the flamegraph zooms in on that element; double clicking on the background (or using the "reset view" button in the upper right) will restore the initial view. Ctrl-Click to open the referenced file.
28+
29+
The tooltip will tell you the number of samples collect in a certain frame as well as the percentage of the top-most displayed frame. There are some heuristics for special flags like garbage collection, dynamic dispatch, and more (these are also color coded).
30+
31+
![flame graph](../images/profiler2.png)
32+
33+
The inline view shows you how much of the parent frame's samples originate on which line (and also the flags, as above, when hovering over the start of the inline annotation):
34+
35+
![inline](../images/profiler3.png)

0 commit comments

Comments
 (0)