Profiling/pl: Difference between revisions

From FreeCAD Documentation
(Created page with "Następnie zwizualizuj te informacje za pomocą {{incode|kcachegrind}} dla systemu Linux lub {{incode|qcachegrind}} dla systemu Windows.")
(Created page with "==Zasoby==")
Line 30: Line 30:
}}
}}


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


* [https://docs.python.org/3/library/profile.html The Python profilers], {{incode|cProfile}} and {{incode|python}}.
* [https://docs.python.org/3/library/profile.html The Python profilers], {{incode|cProfile}} and {{incode|python}}.

Revision as of 18:37, 31 January 2024

Opis

Profilowanie kodu FreeCAD pomaga znaleźć wąskie gardła w algorytmach używanych do tworzenia lub manipulowania obiektami.

Do profilowania kodu Python należy użyć standardowego modułu cProfile, aby zdefiniować punkty początkowe i końcowe do profilowania w kodzie.

import cProfile
pr = cProfile.Profile()
pr.enable()

# --------------------------------------
# Lines of code that you want to profile
# --------------------------------------

pr.disable()
pr.dump_stats("/tmp/profile.cprof")

Następnie zainstaluj i użyj pyprof2calltree, aby przekonwertować dane wyjściowe profilu na dane wejściowe cachegrind.

pyprof2calltree -i /tmp/profile.cprof -o /tmp/callgrind.out

Następnie zwizualizuj te informacje za pomocą kcachegrind dla systemu Linux lub qcachegrind dla systemu Windows.

kcachegrind /tmp/callgrind.out

Zasoby