https://wiki.freecad.org/index.php?title=Profiling/ru&feed=atom&action=historyProfiling/ru - Revision history2024-03-29T05:39:32ZRevision history for this page on the wikiMediaWiki 1.40.1https://wiki.freecad.org/index.php?title=Profiling/ru&diff=836918&oldid=prevBaritone: Created page with "==Описание=="2021-01-07T20:51:51Z<p>Created page with "==Описание=="</p>
<p><b>New page</b></p><div><languages/><br />
<br />
==Описание==<br />
<br />
Profiling the code of FreeCAD helps find bottlenecks in the algorithms used to create or manipulate objects.<br />
<br />
To profile [[Python|Python]] code use the standard {{incode|cProfile}} module to define start and end points to profile in the code.<br />
{{Code|code=<br />
import cProfile<br />
pr = cProfile.Profile()<br />
pr.enable()<br />
<br />
# --------------------------------------<br />
# Lines of code that you want to profile<br />
# --------------------------------------<br />
<br />
pr.disable()<br />
pr.dump_stats("/tmp/profile.cprof")<br />
}}<br />
<br />
Then install and use {{incode|pyprof2calltree}} to convert the profile output into cachegrind input.<br />
{{Code|code=<br />
pyprof2calltree -i /tmp/profile.cprof -o /tmp/callgrind.out<br />
}}<br />
<br />
Then visualize this information with {{incode|kcachegrind}} for Linux or {{incode|qcachegrind}} for Windows.<br />
{{Code|code=<br />
kcachegrind /tmp/callgrind.out<br />
}}<br />
<br />
== Resources ==<br />
<br />
* [https://docs.python.org/3/library/profile.html The Python profilers], {{incode|cProfile}} and {{incode|python}}.<br />
* [https://pypi.org/project/pyprof2calltree/ pyprof2calltree] at PyPI; [https://github.com/pwaller/pyprof2calltree/ pyprof2calltree] repository.<br />
* [https://forum.freecadweb.org/viewtopic.php?f=10&t=44785 FreeCAD's Python profiling tutorial].<br />
<br />
{{Powerdocnavi{{#translation:}}}}<br />
[[Category:Developer Documentation{{#translation:}}]]<br />
[[Category:Python Code{{#translation:}}]]<br />
{{clear}}</div>Baritone