Skip to content

Instantly share code, notes, and snippets.

@jmeggitt
Created August 1, 2022 23:34
Show Gist options
  • Save jmeggitt/6e258fbf5cda86b19865097bb9e23ff0 to your computer and use it in GitHub Desktop.
Save jmeggitt/6e258fbf5cda86b19865097bb9e23ff0 to your computer and use it in GitHub Desktop.
import cProfile, pstats
from pstats import SortKey
pr = cProfile.Profile()
pr.enable()
def end_profile(log_file):
pr.disable()
with open(log_file, "w") as profile_out:
profile_stats = pstats.Stats(pr, stream=profile_out).sort_stats(SortKey.CUMULATIVE)
profile_stats.print_stats()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment