Profilieren

From FreeCAD Documentation
Revision as of 13:19, 26 February 2023 by FBXL5 (talk | contribs)

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