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
- The Python profilers,
cProfile
andpython
. - pyprof2calltree at PyPI; pyprof2calltree repository.
- FreeCAD's Python profiling tutorial.
⏵ documentation index > [Developer Documentation](Category_Developer Documentation.md) > [Python Code](Category_Python Code.md) > Profiling