Skip to content

Commit 48d020d

Browse files
authored
Merge pull request #87 from ubertakter/patch-1
Update profiler.md for profiler macro run note
2 parents 0417f6d + 00749b3 commit 48d020d

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

docs/src/userguide/profiler.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Julia comes with it's own [sampling profiler](https://docs.julialang.org/en/v1/stdlib/Profile/) to measure the CPU time spent in functions or the number and size of allocations. There are [various packages](https://github.com/timholy/FlameGraphs.jl) to visualize these profile traces.
44

55
The VS Code extension comes with helpful macros `@profview` and `@profview_allocs` to run these profilers, and its own profile viewer. Profiling the example function from the [ProfileView.jl readme](https://github.com/timholy/ProfileView.jl)
6+
67
```julia
78
function profile_test(n)
89
for i = 1:n
@@ -21,6 +22,8 @@ end
2122
# pure runtime
2223
@profview profile_test(10)
2324
```
25+
**NOTE:** You must run the `@profview` or `@profview_allocs` macros (and associated function call) in the REPL *in* VS Code. If the REPL terminal window is already open, then you can simply type `@profview profile_test(10)`. Otherwise you can select `Julia: Execute active file in REPL`.
26+
2427
shows a flame graph and inline annotations:
2528
![profiler 1](../images/profiler1.png)
2629

@@ -44,4 +47,4 @@ The allocation profiler works similarly, but shows you the number of allocations
4447

4548
The menu just above the flame graph allows you to toggle between number and size of allocations.
4649

47-
Note that the optional argument `sample_rate` can be used to adjust the number of samples collected. A sample rate of 1.0 will record everything; 0.0 will record nothing. Use this carefully, as a large value can slow down your code significantly. The default value is 0.0001; if you know that allocations are happening but don't see useful information, increase this value gradually.
50+
Note that the optional argument `sample_rate` can be used to adjust the number of samples collected. A sample rate of 1.0 will record everything; 0.0 will record nothing. Use this carefully, as a large value can slow down your code significantly. The default value is 0.0001; if you know that allocations are happening but don't see useful information, increase this value gradually.

0 commit comments

Comments
 (0)