Profiling/pl: Difference between revisions

From FreeCAD Documentation
(Created page with "Tworzenie profili")
 
(Created page with "* [https://docs.python.org/3/library/profile.html Profilery Python], {{incode|cProfile}} i {{incode|python}}. * [https://pypi.org/project/pyprof2calltree/ pyprof2calltree] w PyPI; [https://github.com/pwaller/pyprof2calltree/ pyprof2calltree] repozytorium. * [https://forum.freecadweb.org/viewtopic.php?f=10&t=44785 Poradnik profilowania FreeCAD w Python].")
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
<languages/>
<languages/>


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


Profilowanie kodu FreeCAD pomaga znaleźć wąskie gardła w algorytmach używanych do tworzenia lub manipulowania obiektami.
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.
Do profilowania kodu [[Python/pl|Python]] należy użyć standardowego modułu {{incode|cProfile}}, aby zdefiniować punkty początkowe i końcowe do profilowania w kodzie.
{{Code|code=
{{Code|code=
import cProfile
import cProfile
Line 19: Line 20:
}}
}}


Then install and use {{incode|pyprof2calltree}} to convert the profile output into cachegrind input.
Następnie zainstaluj i użyj {{incode|pyprof2calltree}}, aby przekonwertować dane wyjściowe profilu na dane wejściowe cachegrind.
{{Code|code=
{{Code|code=
pyprof2calltree -i /tmp/profile.cprof -o /tmp/callgrind.out
pyprof2calltree -i /tmp/profile.cprof -o /tmp/callgrind.out
}}
}}


Then visualize this information with {{incode|kcachegrind}} for Linux or {{incode|qcachegrind}} for Windows.
Następnie zwizualizuj te informacje za pomocą {{incode|kcachegrind}} dla systemu Linux lub {{incode|qcachegrind}} dla systemu Windows.
{{Code|code=
{{Code|code=
kcachegrind /tmp/callgrind.out
kcachegrind /tmp/callgrind.out
}}
}}


== 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 Profilery Python], {{incode|cProfile}} i {{incode|python}}.
* [https://pypi.org/project/pyprof2calltree/ pyprof2calltree] at PyPI; [https://github.com/pwaller/pyprof2calltree/ pyprof2calltree] repository.
* [https://pypi.org/project/pyprof2calltree/ pyprof2calltree] w PyPI; [https://github.com/pwaller/pyprof2calltree/ pyprof2calltree] repozytorium.
* [https://forum.freecadweb.org/viewtopic.php?f=10&t=44785 FreeCAD's Python profiling tutorial].
* [https://forum.freecadweb.org/viewtopic.php?f=10&t=44785 Poradnik profilowania FreeCAD w Python].


{{Powerdocnavi{{#translation:}}}}
{{Powerdocnavi{{#translation:}}}}

Latest revision as of 18:39, 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