Profiling/de: Difference between revisions

From FreeCAD Documentation
(Created page with "Dann wird {{incode|pyprof2calltree}} installiert und ausgeführt, um die Ausgabe der Profilierung in eine Eingabe für cachegrind umzuwandeln.")
(Created page with "Danach wird diese Information mit {{incode|kcachegrind}} für Linux oder {{incode|qcachegrind}} für Windows angezeigt.")
 
Line 25: Line 25:
}}
}}


Then visualize this information with {{incode|kcachegrind}} for Linux or {{incode|qcachegrind}} for Windows.
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