Skip to content

Commit 8be9e72

Browse files
committed
Add notes about Python profiling in 1.10.13
1 parent 8c98466 commit 8be9e72

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed
62.7 KB
Loading

optimization/performance-issues/python-calculation.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ not mean you need to abandon Python and rewrite all your code in C++ for that
2020
single bottleneck. Only that single function or class can be ported to C++ and
2121
called from your Python code.
2222

23+
To determine whether it is the Python code that is slowing down an application,
24+
you should :ref:`use PStats <measuring-performance-with-pstats>`. As of Panda3D
25+
version 1.10.13, you can set the ``pstats-python-profiler`` Config.prc variable
26+
to get a detailed view of how much time each Python module, class and function
27+
is taking up. To access this view, in the Frame strip chart, double-click the
28+
App collector on the left side, then double-click the Python collector. Then,
29+
you can drill down further into the packages, modules, classes and functions.
30+
31+
.. image:: pstats-python-time.png
32+
:width: 1005
33+
2334
Before considering writing any C++ code, consider other options:
2435

2536
- See if you can optimize your code. The Python website has a

optimization/using-pstats.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ the profiling machine:
7575
7676
.. only:: python
7777

78+
Profiling Python Code
79+
~~~~~~~~~~~~~~~~~~~~~
80+
7881
If you are developing Python code, you may be interested in reporting the
7982
relative time spent within each Python task (by subdividing the total time
8083
spent in Python, as reported under "Show Code"). To do this, add the
@@ -94,8 +97,12 @@ the profiling machine:
9497
9598
pstats-python-profiler 1
9699
97-
Caveats
98-
~~~~~~~
100+
To access this view, in the Frame strip chart, double-click the App collector
101+
on the left side, then double-click the Python collector. Then, you can drill
102+
down further into the packages, modules, classes and functions.
103+
104+
Profiling GPU Time
105+
~~~~~~~~~~~~~~~~~~
99106

100107
OpenGL is asynchronous, which means that function calls aren't guaranteed to
101108
execute right away. This can make performance analysis of OpenGL operations

0 commit comments

Comments
 (0)