Profiling/de: Difference between revisions

From FreeCAD Documentation
No edit summary
No edit summary
Line 6: Line 6:
Das Profilieren des Codes von FreeCAD hilft Flaschenhälse in den Algorithmen zu finden, die zur Erstellung oder Bearbeitung von Objekten verwendet werden.
Das Profilieren des Codes von FreeCAD hilft Flaschenhälse in den Algorithmen zu finden, die zur Erstellung oder Bearbeitung von Objekten verwendet werden.


Um [[Python/de|Python]] Code zu profilieren, verwende das Standardmodul {{incode|cProfile}}, um Start und Endpunkte des Profils im Code zu definieren.
Zum Profilieren des [[Python/de|Python]]-Codes, wird das Standardmodul {{incode|cProfile}} verwendet, um Start- und Endpunkte der Profilierung im Code zu definieren.
{{Code|code=
{{Code|code=
import cProfile
import cProfile

Revision as of 13:23, 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")

Then install and use pyprof2calltree to convert the profile output into cachegrind input.

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

Ressourcen