Profilage

From FreeCAD Documentation
This page is a translated version of the page Profiling and the translation is 100% complete.
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