Profiling/fr: Difference between revisions

From FreeCAD Documentation
(Created page with "Pour profiler le code Python, utilisez le module standard {{incode|cProfile}} pour définir les points de début et de fin du profil dans le code.")
(Updating to match new version of source page)
 
(4 intermediate revisions by one other user not shown)
Line 19: Line 19:
}}
}}


Then install and use {{incode|pyprof2calltree}} to convert the profile output into cachegrind input.
Ensuite, installez et utilisez {{incode|pyprof2calltree}} pour convertir la sortie du profil en entrée cachegrind.
{{Code|code=
{{Code|code=
pyprof2calltree -i /tmp/profile.cprof -o /tmp/callgrind.out
pyprof2calltree -i /tmp/profile.cprof -o /tmp/callgrind.out
}}
}}


Then visualize this information with {{incode|kcachegrind}} for Linux or {{incode|qcachegrind}} for Windows.
Ensuite, visualisez ces informations avec {{incode|kcachegrind}} pour Linux ou {{incode|qcachegrind}} pour Windows.
{{Code|code=
{{Code|code=
kcachegrind /tmp/callgrind.out
kcachegrind /tmp/callgrind.out
}}
}}


== Resources ==
==Ressources==


* [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}} et {{incode|python}}.
* [https://pypi.org/project/pyprof2calltree/ pyprof2calltree] at PyPI; [https://github.com/pwaller/pyprof2calltree/ pyprof2calltree] repository.
* [https://pypi.org/project/pyprof2calltree/ pyprof2calltree] à PyPI; dépôt [https://github.com/pwaller/pyprof2calltree/ pyprof2calltree].
* [https://forum.freecadweb.org/viewtopic.php?f=10&t=44785 FreeCAD's Python profiling tutorial].
* [https://forum.freecadweb.org/viewtopic.php?f=10&t=44785 FreeCAD's Python profiling tutorial].


{{Powerdocnavi{{#translation:}}}}
{{Powerdocnavi{{#translation:}}}}
[[Category:Developer Documentation{{#translation:}}]]
[[Category:Python Code{{#translation:}}]]
{{clear}}

Latest revision as of 21:06, 22 August 2020

Other languages:

Description

Le profilage du code de FreeCAD permet de trouver des goulots d'étranglement dans les algorithmes utilisés pour créer ou manipuler des objets.

Pour profiler le code Python, utilisez le module standard cProfile pour définir les points de début et de fin du profil dans le code.

import cProfile
pr = cProfile.Profile()
pr.enable()

# --------------------------------------
# Lines of code that you want to profile
# --------------------------------------

pr.disable()
pr.dump_stats("/tmp/profile.cprof")

Ensuite, installez et utilisez pyprof2calltree pour convertir la sortie du profil en entrée cachegrind.

pyprof2calltree -i /tmp/profile.cprof -o /tmp/callgrind.out

Ensuite, visualisez ces informations avec kcachegrind pour Linux ou qcachegrind pour Windows.

kcachegrind /tmp/callgrind.out

Ressources