@@ -65,18 +65,51 @@ The PStats server interface will remain open, giving you a chance to further
6565analyze the data or save it to disk. You need to close the existing session and
6666click "New Session" before you can reconnect a new client.
6767
68- Task Profiling
69- --------------
68+ .. only :: python
7069
71- If you are developing Python code, you may be interested in reporting the
72- relative time spent within each Python task (by subdividing the total time spent
73- in Python, as reported under "Show Code"). To do this, add the following lines
74- to your Config.prc file before you start ShowBase:
70+ .. _pstats-python-profiler :
7571
76- .. code-block :: text
72+ Profiling Python Code
73+ ---------------------
74+
75+ If you are developing Python code, you may be interested in reporting the
76+ relative time spent within each Python task (by subdividing the total time
77+ spent in Python code, as reported under "App:Tasks"). To do this, add the
78+ following line to your Config.prc file before you start ShowBase:
79+
80+ .. code-block :: text
81+
82+ pstats-tasks 1
83+
84+ However, it can be even more useful to enable the Python profiler feature,
85+ which collects detailed information about the individual function calls made
86+ by the Python interpreter. There is a performance cost to this feature, which
87+ is why it is not enabled by default. To enable it, use the following setting:
88+
89+ .. code-block :: text
90+
91+ pstats-python-profiler 1
92+
93+ To get a hierarchical breakdown of the time taken by a particular Python
94+ module, class or function, use the Strip Chart view and double-click the App,
95+ then the Python label on the left side. Then, you can drill down into the
96+ specific Python packages, modules and functions:
97+
98+ .. image :: strip-chart-python-time.png
99+ :width: 1005
100+
101+ The time-based strip charts just collect the total time spent executing a
102+ particular function, without any information about what other functions a
103+ particular function is calling or is called by. Use the Flame Graph view to
104+ see call graph information:
105+
106+ .. image :: flame-graph-python.png
107+ :width: 747
77108
78- task-timer-verbose 1
79- pstats-tasks 1
109+ You can hover the mouse over the individual bars to see the full name, exact
110+ time and call count of the given function within its parent scope.
111+ Double-clicking a bar will narrow down the view to only that function and any
112+ functions called by it, and double-clicking the white space will go back.
80113
81114Remote Profiling
82115----------------
0 commit comments