Read the profiler snapshot
In the Profiler tool window ( ), the collected data is presented on several tabs: Flame Graph, Call Tree, Method List, Statistics, and Call Graph.
Navigate the snapshot
You can jump between the tabs while staying focused on a specific method. Right-click the necessary method and select another view in which you want to open it.
For any method on the Flame Graph, Call Tree and Method List tabs, you can open the Merged Callees and Back Traces trees. Right-click the method and select Method Merged Callees or Method Back Traces respectively.
Threads
The profiling data in the Profiler tool window tabs is grouped by thread. You can select to view merged data for the entire process (All threads merged) or select a specific thread for closer investigation.
Show threads
By default, the list of threads is hidden, and the data is shown for all threads combined.
To select a particular thread or review the list of threads, click the Show Threads View in the left-hand toolbar.
The threads are listed on the left-hand side of the Profiler tool window and sorted by the number of collected samples. Thus, you can find the most busy threads at the top of the list.
Flame Graph
The flame graph visualizes the application call tree with the rectangles that stand for frames of the call stack, ordered by width.
Get call details
Hover over a block to see the tooltip with frame details. The tooltip shows the share of time in the entire snapshot and in the frame's direct parent.
Zoom the graph
Use the and buttons on the flame graph's toolbar or the scroll wheel to zoom the graph.
To focus on a specific method, double-click the corresponding block on the graph.
To restore the original size of the graph, click 1:1 on the toolbar.
Search the graph
If you want to locate a specific method on the graph, start typing its name or click and type the name in the search bar.
The graph highlights all blocks with method names matching your search request.
Use and for fast navigation between search results. Using the buttons on the toolbar, you can also search either the whole graph or a specific subtree and navigate to the results as soon as something was found.
Capture the graph
You can capture and export the graph separately from other data in the snapshot.
Click and select Copy to Clipboard or click Save to export the graph as an image in the .png format.
You can visualize the difference between two snapshots on the flame graph.
Compare with a baseline
Open two snapshots. To open snapshots, you can run the profiler twice or go to
and select snapshots here.Click the Compare With Baseline button and select the snapshot that you want to compare against.
A separate diff tab will open with the results of the comparison, combining two flame graphs and showing the differences as red and green.
If you see that some part of the frame is green, it means that the corresponding method became faster during this profiler run. The red color means that the corresponding method became slower.
Call Tree
The Call Tree tab organizes the sampled data in a tree-like structure.
For each method, the tab shows the following information:
Share in the total execution time or parent's execution time
The aggregated execution time
Recursive calls
By default, the percentage is relative to the total execution time. You can choose to view the numbers relative to the parent frame.
Switch the percentage between total and parent
Click and select Show Percent of Total Time or Show Percent of Parent.
What-if: focus on specific methods
PyCharm allows you to examine specific nodes and subtrees in the Call Tree: you can exclude particular methods or the other way round, focus only on the nodes in which you are interested at the moment.
Right-click the necessary node on the Call Tree tab and select one of the following options to open the results in a dedicated tab:
Focus On Subtree: show only the selected method call. Parent method sample counter shows only the time spent in the selected subtree.
Focus On Call: show the selected method and the methods that call it. When this option is enabled, every frame shows only the time spent in the selected method.
Exclude Subtree: ignore the selected method call.
Exclude Call: ignore all calls to the selected method.
Method List
The Method List collects all methods in the profile data and sorts them by cumulative sample time. Every item in this list has several views:
Back Traces shows the hierarchy of callers. Use this view to trace which methods call the selected method.
Merged Callees is the call tree summarizing the methods down the call hierarchy.
Callee List is the method list summarizing the methods down the call hierarchy.
Statistics
In the Statistics tab, you can inspect profiling results:
Item | Description |
---|---|
Name | The name of the function. |
Call Count | Number of calls of the chosen function. |
Time | Execution time of the chosen function plus all time taken by functions called by this function. The percentage of time spent in this call related to time spent in all calls in the parentheses. |
Own Time | Own execution time of the chosen function. The percentage of own time spent in this call related to overall time spent in this call in the parentheses. |
Jump to the source code
To navigate to the source code of a certain function, right-click the corresponding entry on the Statistics tab, and select from the context menu:
The source code of the function opens in the editor.
Call Graph
Note the color codes on the Call Graph: the functions marked red consume more time; the fastest functions are green.
Use the toolbar buttons to work with the graph:
Item
Description
Click this icon to increase the scale of the diagram. Alternatively, press NumPad+.
Click this icon to decrease the scale of the diagram. Alternatively, press NumPad-.
Click this icon to restore the actual size of the diagram.
Click this icon to make the contents fit into the current diagram size.
Click this icon to apply the current layout, selected from the Layout node of the diagram context menu.
Click this icon to scale the diagram to the edges of the window.
Click this icon to copy the diagram into the clipboard.
Click this icon and then select any diagram area with the mouse: the selected area will be copied into the clipboard.
Click this icon to export the current diagram to the PNG format.
Click this icon to print the diagram.