Profiling/de: Difference between revisions

From FreeCAD Documentation
(Created page with "== Beschreibung ==")
 
(Created page with "Die Profilerstellung im Code von FreeCAD hilft, Flaschenhälse in den Algorithmen zu finden, die zur Erstellung oder Manipulation von Objekten verwendet werden.")
Line 3: Line 3:
== Beschreibung ==
== Beschreibung ==


Die Profilerstellung im Code von FreeCAD hilft, Flaschenhälse in den Algorithmen zu finden, die zur Erstellung oder Manipulation von Objekten verwendet werden.
Profiling the code of FreeCAD helps find bottlenecks in the algorithms used to create or manipulate objects.


To profile [[Python|Python]] code use the standard {{incode|cProfile}} module to define start and end points to profile in the code.
To profile [[Python|Python]] code use the standard {{incode|cProfile}} module to define start and end points to profile in the code.

Revision as of 22:09, 16 August 2020

Beschreibung

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

To profile Python code use the standard cProfile module to define start and end points to profile in the code.

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

Resources