From 00749b35b0430822d0ae02a0b762fe6748876c90 Mon Sep 17 00:00:00 2001 From: ubertakter Date: Tue, 10 Sep 2024 13:42:37 -0500 Subject: [PATCH] Update profiler.md for profiler macro run note Added a note in the profiler documentation that the profiler macros must be run from the REPL and not from a new environment. --- docs/src/userguide/profiler.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/src/userguide/profiler.md b/docs/src/userguide/profiler.md index 5e50a0f..e866f50 100644 --- a/docs/src/userguide/profiler.md +++ b/docs/src/userguide/profiler.md @@ -3,6 +3,7 @@ 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. 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) + ```julia function profile_test(n) for i = 1:n @@ -21,6 +22,8 @@ end # pure runtime @profview profile_test(10) ``` +**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`. + shows a flame graph and inline annotations: ![profiler 1](../images/profiler1.png) @@ -44,4 +47,4 @@ The allocation profiler works similarly, but shows you the number of allocations The menu just above the flame graph allows you to toggle between number and size of allocations. -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. \ No newline at end of file +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.