Profiling: Difference between revisions
(Profiling the code of FreeCAD helps find bottlenecks in the algorithms used to create or manipulate objects.) |
Renatorivo (talk | contribs) (Marked this version for translation) |
||
Line 2: | Line 2: | ||
<translate> |
<translate> |
||
== Description == |
== Description == <!--T:1--> |
||
<!--T:2--> |
|||
Profiling the code of FreeCAD helps find bottlenecks in the algorithms used to create or manipulate objects. |
Profiling the code of FreeCAD helps find bottlenecks in the algorithms used to create or manipulate objects. |
||
<!--T:3--> |
|||
To profile [[Python|Python]] code use the standard {{incode|cProfile}} module to define start and end points to profile in the code. |
To profile [[Python|Python]] code use the standard {{incode|cProfile}} module to define start and end points to profile in the code. |
||
</translate> |
</translate> |
||
Line 22: | Line 24: | ||
<translate> |
<translate> |
||
<!--T:4--> |
|||
Then install and use {{incode|pyprof2calltree}} to convert the profile output into cachegrind input. |
Then install and use {{incode|pyprof2calltree}} to convert the profile output into cachegrind input. |
||
</translate> |
</translate> |
||
Line 29: | Line 32: | ||
<translate> |
<translate> |
||
<!--T:5--> |
|||
Then visualize this information with {{incode|kcachegrind}} for Linux or {{incode|qcachegrind}} for Windows. |
Then visualize this information with {{incode|kcachegrind}} for Linux or {{incode|qcachegrind}} for Windows. |
||
</translate> |
</translate> |
||
Line 36: | Line 40: | ||
<translate> |
<translate> |
||
== Resources == |
== Resources == <!--T:6--> |
||
<!--T:7--> |
|||
* [https://docs.python.org/3/library/profile.html The Python profilers], {{incode|cProfile}} and {{incode|python}}. |
* [https://docs.python.org/3/library/profile.html The Python profilers], {{incode|cProfile}} and {{incode|python}}. |
||
* [https://pypi.org/project/pyprof2calltree/ pyprof2calltree] at PyPI; [https://github.com/pwaller/pyprof2calltree/ pyprof2calltree] repository. |
* [https://pypi.org/project/pyprof2calltree/ pyprof2calltree] at PyPI; [https://github.com/pwaller/pyprof2calltree/ pyprof2calltree] repository. |
Revision as of 16:46, 12 August 2020
Description
Profiling the code of FreeCAD helps find bottlenecks in the algorithms used to create or manipulate objects.
To profile Python code use the standard cProfile
module to define start and end points to profile in the code.
import cProfile
pr = cProfile.Profile()
pr.enable()
# --------------------------------------
# Lines of code that you want to profile
# --------------------------------------
pr.disable()
pr.dump_stats("/tmp/profile.cprof")
Then install and use pyprof2calltree
to convert the profile output into cachegrind input.
pyprof2calltree -i /tmp/profile.cprof -o /tmp/callgrind.out
Then visualize this information with kcachegrind
for Linux or qcachegrind
for Windows.
kcachegrind /tmp/callgrind.out
Resources
- The Python profilers,
cProfile
andpython
. - pyprof2calltree at PyPI; pyprof2calltree repository.
- FreeCAD's Python profiling tutorial.
Power user documentation
- FreeCAD scripting: Python, Introduction to Python, Python scripting tutorial, FreeCAD Scripting Basics
- Modules: Builtin modules, Units, Quantity
- Workbenches: Workbench creation, Gui Commands, Commands, Installing more workbenches
- Meshes and Parts: Mesh Scripting, Topological data scripting, Mesh to Part, PythonOCC
- Parametric objects: Scripted objects, Viewproviders (Custom icon in tree view)
- Scenegraph: Coin (Inventor) scenegraph, Pivy
- Graphical interface: Interface creation, Interface creation completely in Python (1, 2, 3, 4, 5), PySide, PySide examples beginner, intermediate, advanced
- Macros: Macros, How to install macros
- Embedding: Embedding FreeCAD, Embedding FreeCADGui
- Other: Expressions, Code snippets, Line drawing function, FreeCAD vector math library (deprecated)
- Hubs: User hub, Power users hub, Developer hub