Jump to content

Profilieren

From FreeCAD Documentation
Revision as of 07:43, 14 November 2025 by C4e (talk | contribs) (Created page with "* [https://docs.python.org/3/library/profile.html The Python profilers], {{incode|cProfile}} und {{incode|python}}. * [https://pypi.org/project/pyprof2calltree/ pyprof2calltree] auf PyPI; [https://github.com/pwaller/pyprof2calltree/ pyprof2calltree] Verzeichnis. * [https://forum.freecad.org/viewtopic.php?f=10&t=44785 FreeCAD's Python profiling tutorial].")

(diff) ← Older revision | Approved revision (diff) | Latest revision (diff) | Newer revision → (diff)

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