cProfile.Profile.enable()
cProfile.Profile.enable() is a Python method in the CProfile Module category. Starts collecting profiling data. The syntax is Profile.enable(). Returns: None. A typical example: prof = cProfile.Profile()
prof.enable()
# Code to profile
prof.disable()
prof.print_stats(sort="cumtime"). A close sibling is cProfile.run(), which runs a Python statement under the profiler and prints statistics. A close sibling is cProfile.runctx(), which runs a command with explicit globals/locals under the profiler. A close sibling is cProfile.Profile.dump_stats(), which writes profiling data to a file (can be analyzed with pstats). More about this category: Performance profiler — run, runctx, Profile, enable, disable, dump_stats. Related CProfile Module entries: cProfile.run(), cProfile.runctx(), cProfile.Profile.dump_stats(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details. You can try cProfile.Profile.enable() immediately in the Python playground, look up unfamiliar terms in the glossary, or return to the Python Reference homepage.