GoLand 2023.2 Help

CPU profiler

CPU Profiler shows what functions consume what percent of CPU time This information can provide you a better understanding of how your application is executed, and how exactly resources are allocated.

Once the analysis is finished, the profiler visualizes the output data in the re.ports.

Profiler configuration

GoLand features two pre-defined Async Profiler configurations: the CPU profiler and the memory allocation profiler that you can find in Settings | Build, Execution, Deployment | Java Profiler.

These configurations are adjusted to provide the most accurate results, that is why they don't require any modifications. However, if you still need to change the settings, refer to Async Profiler on GitHub for more information.

Select the profiler configuration

  1. In the Settings dialog (Control+Alt+S), select Build, Execution, Deployment | Go Profiler.

  2. Select one of the pre-defined CPU or memory profiling configuration or create a new one by clicking the Add button.

  3. Apply the changes and close the dialog.

Run profiling

Run CPU profiling

  1. Open the _test.go file.

  2. Near the function or method that you want to profile, click the Run Application icon the Run Application icon in the gutter area and select Run <configuration_name> with 'CPU Profiler'.

Run CPU profiling

Read the profiling report

In the Profiler tool window, the collected data is presented on three tabs: Flame Graph, Call Tree, and Method List. The left-hand part lists application threads; by clicking on each thread you can go in more details.

Flame Graph

The Flame Graph tab shows you function calls and the percentage of time for execution of each call. Each block represents a function in the stack (a stack frame). On the Y-axis, there is a stack depth going from bottom up. The X-axis shows the stack profile sorted from the most CPU-consuming functions to the least consuming ones.

When you read the flame graph, focus on the widest blocks. These blocks are the functions that are presented in the profile most.

Hover the mouse over any block to view the details:

block details in the flame chart

Call Tree

The Call Tree tab represents information about a program’s call stacks that were sampled during profiling:

  • The method name

  • Percentage of total sample time (can be toggled to the parent call view)

  • The total sample count

  • The number of filtered calls

The optional number right after the percentage presents a filtered sequence of calls. Click it to expand this sequence. The filtering rules can be configured in the settings.

To configure and filter the Call Tree view, use the Presentation Settings button (the Presentation Settings button).

call tree tab in the profiler results

Method List

The Method List collects all methods in the profiled data and sorts them by cumulative sample time. Every item in this list has a Back Trace tree and a Merge Callees tree.

The Back Traces tab shows the hierarchy of callers. Use this view to trace which methods call the selected method. Merge Callees tries to summarize all methods that are called by the selected one.

method list tab in the profiler results
Last modified: 15 August 2023