Skip to content

Instantly share code, notes, and snippets.

@matanper
matanper / python_run_time_profiler.py
Created May 15, 2022 07:56
Python code snippet to run run-time profiling for python code
import cProfile
import io
import pstats
pr = cProfile.Profile()
pr.enable()
### Code to profile here
pr.disable()
s = io.StringIO()
ps = pstats.Stats(pr, stream=s).sort_stats('time')