Profiling
Description
Profiling the code of FreeCAD helps find bottlenecks in the algorithms used to create or manipulate objects.
To profile Python code use the standard
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 -i /tmp/profile.cprof -o /tmp/callgrind.out
Then visualize this information with
kcachegrind /tmp/callgrind.out
Resources
- The Python profilers,
cProfile
andpython
. - pyprof2calltree at PyPI; pyprof2calltree repository.
- FreeCAD\'s Python profiling tutorial.
⏵ documentation index > Developer Documentation > Python Code > Profiling
This page is retrieved from https://github.com/FreeCAD/FreeCAD-documentation/blob/main/wiki/Profiling.md