Profiling/de: Difference between revisions

From FreeCAD Documentation
(Updating to match new version of source page)
No edit summary
Line 1: Line 1:
<languages/>
<languages/>


<span id="Description"></span>
== Beschreibung ==
== Beschreibung ==


Line 29: Line 30:
}}
}}


<span id="Resources"></span>
== Ressourcen ==
== Ressourcen ==



Revision as of 13:19, 26 February 2023

Beschreibung

Die Profilerstellung im Code von FreeCAD hilft, Flaschenhälse in den Algorithmen zu finden, die zur Erstellung oder Manipulation von Objekten verwendet werden.

Um Python Code zu profilieren, verwende das Standardmodul cProfile, um Start und Endpunkte des Profils 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