Profiling/it: Difference between revisions
Renatorivo (talk | contribs) (Created page with "Per profilare il codice Python usare il modulo standard {{incode|cProfile}} per definire i punti di inizio e fine del profilo nel codice.") |
Renatorivo (talk | contribs) (Created page with "Quindi installare e usare {{incode|pyprof2calltree}} per convertire l'output del profilo in input di cachegrind.") |
||
Line 19: | Line 19: | ||
}} |
}} |
||
Quindi installare e usare {{incode|pyprof2calltree}} per convertire l'output del profilo in input di cachegrind. |
|||
{{Code|code= |
{{Code|code= |
||
pyprof2calltree -i /tmp/profile.cprof -o /tmp/callgrind.out |
pyprof2calltree -i /tmp/profile.cprof -o /tmp/callgrind.out |
Revision as of 20:48, 4 September 2020
Descrizione
La profilazione del codice di FreeCAD aiuta a trovare i colli di bottiglia negli algoritmi utilizzati per creare o manipolare oggetti.
Per profilare il codice Python usare il modulo standard cProfile
per definire i punti di inizio e fine del profilo nel codice.
import cProfile
pr = cProfile.Profile()
pr.enable()
# --------------------------------------
# Lines of code that you want to profile
# --------------------------------------
pr.disable()
pr.dump_stats("/tmp/profile.cprof")
Quindi installare e usare pyprof2calltree
per convertire l'output del profilo in input di cachegrind.
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