Profiling/de: Difference between revisions
No edit summary |
(Created page with "Danach wird diese Information mit {{incode|kcachegrind}} für Linux oder {{incode|qcachegrind}} für Windows angezeigt.") |
||
(3 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
== Beschreibung == |
== Beschreibung == |
||
Das Profilieren des Codes von FreeCAD hilft Flaschenhälse in den Algorithmen zu finden, die zur Erstellung oder Bearbeitung von Objekten verwendet werden. |
|||
Zum Profilieren des [[Python/de|Python]]-Codes, wird das Standardmodul {{incode|cProfile}} verwendet, um Start- und Endpunkte der Profilierung im Code zu definieren. |
|||
{{Code|code= |
{{Code|code= |
||
import cProfile |
import cProfile |
||
Line 20: | Line 20: | ||
}} |
}} |
||
Dann wird {{incode|pyprof2calltree}} installiert und ausgeführt, um die Ausgabe der Profilierung in eine Eingabe für cachegrind umzuwandeln. |
|||
{{Code|code= |
{{Code|code= |
||
pyprof2calltree -i /tmp/profile.cprof -o /tmp/callgrind.out |
pyprof2calltree -i /tmp/profile.cprof -o /tmp/callgrind.out |
||
}} |
}} |
||
Danach wird diese Information mit {{incode|kcachegrind}} für Linux oder {{incode|qcachegrind}} für Windows angezeigt. |
|||
{{Code|code= |
{{Code|code= |
||
kcachegrind /tmp/callgrind.out |
kcachegrind /tmp/callgrind.out |
Latest revision as of 13:28, 26 February 2023
Beschreibung
Das Profilieren des Codes von FreeCAD hilft Flaschenhälse in den Algorithmen zu finden, die zur Erstellung oder Bearbeitung von Objekten verwendet werden.
Zum Profilieren des Python-Codes, wird das Standardmodul cProfile
verwendet, um Start- und Endpunkte der Profilierung im Code zu definieren.
import cProfile
pr = cProfile.Profile()
pr.enable()
# --------------------------------------
# Lines of code that you want to profile
# --------------------------------------
pr.disable()
pr.dump_stats("/tmp/profile.cprof")
Dann wird pyprof2calltree
installiert und ausgeführt, um die Ausgabe der Profilierung in eine Eingabe für cachegrind umzuwandeln.
pyprof2calltree -i /tmp/profile.cprof -o /tmp/callgrind.out
Danach wird diese Information mit kcachegrind
für Linux oder qcachegrind
für Windows angezeigt.
kcachegrind /tmp/callgrind.out
Ressourcen
- 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